From 0a6f5533ee0d4b8bab4f0d9e355eb1fac7e234d9 Mon Sep 17 00:00:00 2001 From: karutoh Date: Mon, 18 Dec 2023 02:13:20 -0800 Subject: [PATCH] Fixed all errors. --- include/Array.h | 67 ++++---- include/BaseObj.h | 71 ++------ include/EHS.h | 2 +- include/Log.h | 4 +- include/Serializer.h | 70 ++++---- include/Str.h | 88 +++++----- include/Type.h | 40 +++-- include/Vector.h | 31 +++- include/io/FontAtlas.h | 6 +- include/io/audio/Audio.h | 87 +++++----- include/io/img/Img.h | 21 ++- include/io/model/Mesh.h | 25 +-- include/io/model/Model.h | 22 +-- include/io/model/Vertex.h | 1 + include/io/socket/Comms.h | 2 + include/io/socket/Endpoint.h | 6 +- src/BaseObj.cpp | 217 +++++++++++++----------- src/EHS.cpp | 70 ++++---- src/GarbageCollector.cpp | 6 - src/HRNG_GCC.asm | 96 +++++------ src/HRNG_MSVC.asm | 96 +++++------ src/Math_GCC_AMD64.asm | 48 +++--- src/Math_MSVC_AMD64.asm | 48 +++--- src/StrToHash.cpp | 20 +-- src/Task.cpp | 2 +- src/Type.cpp | 147 ++++++++--------- src/io/FontAtlas.cpp | 11 +- src/io/Window_XCB.cpp | 2 + src/io/audio/Audio.cpp | 122 +++++++++----- src/io/img/Img.cpp | 112 ++++++++----- src/io/model/Mesh.cpp | 263 ++++-------------------------- src/io/model/Model.cpp | 80 ++++----- src/io/socket/Comms.cpp | 9 +- src/io/socket/Endpoint.cpp | 78 +++------ src/io/socket/rest/TwitchChat.cpp | 2 +- src/system/CPU_GCC_AMD64.asm | 36 ++-- src/system/CPU_MSVC_AMD64.asm | 32 ++-- 37 files changed, 950 insertions(+), 1090 deletions(-) diff --git a/include/Array.h b/include/Array.h index 3af0e90..fe52663 100644 --- a/include/Array.h +++ b/include/Array.h @@ -1,6 +1,7 @@ #pragma once -#include "EHS.h" +#include "Types.h" +#include "BaseObj.h" #include #include @@ -11,7 +12,7 @@ namespace ehs /// @tparam T Array data type to use. /// @tparam N Number data type to use. template - class Array + class Array : public BaseObj { protected: T* data; @@ -19,7 +20,7 @@ namespace ehs public: /// Frees any data created on the heap. - ~Array() + ~Array() override { delete[] data; } @@ -28,20 +29,24 @@ namespace ehs Array() : data(nullptr), size(0) { + AddType("Array"); } /// Initializes an empty array with the given size. /// @note Data must be assigned manually using an index. explicit Array(const N size) - : data(new T[size]), size(size) + : data(new T[size]), size(size) { + AddType("Array"); } /// Initializes this array with an initializer list object. /// @param [in] list The given initializer list. Array(std::initializer_list list) - : data(new T[list.size()]), size(list.size()) + : data(new T[list.size()]), size(list.size()) { + AddType("Array"); + N i = 0; for (auto v = list.begin(); v != list.end(); ++v) data[i++] = std::move(*v); @@ -51,27 +56,46 @@ namespace ehs /// @param [in] data The C-style array. /// @param [in] size The size of the given C-style array. Array(const T* const data, const N size) - : data(new T[size]), size(size) + : data(new T[size]), size(size) { + AddType("Array"); + for (N i = 0; i < size; ++i) this->data[i] = data[i]; } + Array(Array&& array) noexcept + : BaseObj(array), data(array.data), size(array.size) + { + array.data = nullptr; + array.size = 0; + } + /// Copies all members from the given array object. /// @param [in] array The array object to copy from. Array(const Array& array) - : data(new T[array.size]), size(array.size) + : BaseObj((BaseObj&&)array), data(new T[array.size]), size(array.size) { for (N i = 0; i < size; ++i) data[i] = array.data[i]; } - Array(Array&& array) noexcept - : data(array.data), size(array.size) - { - array.data = nullptr; - array.size = 0; - } + Array& operator=(Array&& array) noexcept + { + if (this == &array) + return *this; + + BaseObj::operator=((BaseObj&&)array); + + delete[] data; + data = array.data; + size = array.size; + + array.data = nullptr; + array.size = 0; + + return *this; + } /// Copies all members from the given array object. /// @param [in] array The array object to copy from. @@ -81,6 +105,8 @@ namespace ehs if (this == &array) return *this; + BaseObj::operator=(array); + delete[] data; data = new T[array.size]; for (N i = 0; i < array.size; ++i) @@ -91,21 +117,6 @@ namespace ehs return *this; } - Array& operator=(Array&& array) noexcept - { - if (this == &array) - return *this; - - delete[] data; - data = array.data; - size = array.size; - - array.data = nullptr; - array.size = 0; - - return *this; - } - /// Copies all members from the given initializer list object. /// @param [in] list The initializer list object to copy from. /// @returns The array that has been assigned to. diff --git a/include/BaseObj.h b/include/BaseObj.h index 4dd1a14..d87ac99 100644 --- a/include/BaseObj.h +++ b/include/BaseObj.h @@ -1,95 +1,52 @@ #pragma once -#include "EHS.h" +#include "Types.h" #include "Type.h" -#include "Array.h" -#include "Log.h" namespace ehs { class BaseObj { private: - Array hierarchy; - BaseObj* parent; + Type* hierarchy; + UInt_64 hierarchySize; public: virtual ~BaseObj(); BaseObj(); + BaseObj(BaseObj&& base) noexcept; + BaseObj(const BaseObj& base); - BaseObj(BaseObj&& base) noexcept; + BaseObj& operator=(BaseObj&& base) noexcept; BaseObj& operator=(const BaseObj& base); - BaseObj& operator=(BaseObj&& base) noexcept; - - bool operator!() const; - bool operator==(const BaseObj& base) const; bool operator!=(const BaseObj& base) const; - bool HasType(const UInt_64 hashType) const; + const Type* GetHierarchy() const; - bool HasType(const Str_8& type) const; + UInt_64 GetHierarchySize() const; - protected: - bool AddType(Str_8 type); + bool HasType(UInt_64 typeHashId) const; + + bool HasType(const Char_8* typeId) const; - public: Type GetType() const; - Type GetType(const UInt_64 hashType) const; - - Type GetType(const Str_8& type) const; + UInt_64 GetTypeIdSize() const; const Char_8* GetTypeId() const; UInt_64 GetTypeHashId() const; - const Array& GetHierarchy() const; - - void SetParent(BaseObj* newParent); - - BaseObj* GetParent(); - - BaseObj* GetParent(const UInt_64 hashType); - - BaseObj* GetParent(const Str_8& type); - virtual BaseObj* Clone() const; - virtual bool IsValid() const; + protected: + void AddType(const Char_8* id); }; - - inline bool BaseObj::HasType(const UInt_64 hashType) const - { - for (UInt_64 i = 0; i < hierarchy.Size(); ++i) - if (hashType == hierarchy[i].GetHashId()) - return true; - - return false; - } - - inline Type BaseObj::GetType(const UInt_64 hashType) const - { - for (UInt_64 i = 0; i < hierarchy.Size(); ++i) - if (hashType == hierarchy[i].GetHashId()) - return hierarchy[i]; - - return {}; - } - - inline BaseObj* BaseObj::GetParent(const UInt_64 hashType) - { - BaseObj* result = GetParent(); - - while (result && !result->HasType(hashType)) - result = result->GetParent(); - - return result; - } } \ No newline at end of file diff --git a/include/EHS.h b/include/EHS.h index 0fdff8b..78c109c 100644 --- a/include/EHS.h +++ b/include/EHS.h @@ -60,4 +60,4 @@ namespace ehs Version GetAppVersion(); }; -extern lwe::SInt_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVer); \ No newline at end of file +extern ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer); \ No newline at end of file diff --git a/include/Log.h b/include/Log.h index c4f670c..a33620f 100644 --- a/include/Log.h +++ b/include/Log.h @@ -109,8 +109,8 @@ namespace ehs #ifndef EHS_LOG #ifdef EHS_DEBUG - #define EHS_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), EHS_FILE, EHS_FUNC, lwe::Str_8::FromNum((lwe::UInt_32)EHS_LINE)}, code, msg}) + #define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg}) #else - #define EHS_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), EHS_FUNC}, code, msg}) + #define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FUNC}, code, msg}) #endif #endif \ No newline at end of file diff --git a/include/Serializer.h b/include/Serializer.h index cf94d54..eabc389 100644 --- a/include/Serializer.h +++ b/include/Serializer.h @@ -1,6 +1,7 @@ #pragma once -#include "EHS.h" +#include "Types.h" +#include "BaseObj.h" #include "Util.h" #include "Array.h" #include "Vector.h" @@ -20,7 +21,7 @@ namespace ehs { template - class Serializer + class Serializer : public BaseObj { private: Endianness endianness; @@ -29,7 +30,7 @@ namespace ehs N offset; public: - ~Serializer() + ~Serializer() override { delete[] data; } @@ -37,45 +38,74 @@ namespace ehs Serializer() : endianness(Endianness::BE), data(nullptr), size(0), offset(0) { + AddType("Serializer"); } Serializer(const Endianness endianness) : endianness(endianness), data(nullptr), size(0), offset(0) { + AddType("Serializer"); } Serializer(const Endianness endianness, const N size) : endianness(endianness), data(new Byte[size]), size(size), offset(0) { + AddType("Serializer"); } Serializer(const Endianness endianness, const Byte* const data, const N size, const N offset = 0) : endianness(endianness), data(new Byte[size]), size(size), offset(offset) { + AddType("Serializer"); + for (N i = 0; i < size; ++i) this->data[i] = data[i]; } - Serializer(const Serializer& serializer) - : endianness(serializer.endianness), data(new Byte[serializer.size]), size(serializer.size), offset(serializer.offset) - { - for (N i = 0; i < serializer.size; ++i) - data[i] = serializer.data[i]; - } - Serializer(Serializer&& serializer) noexcept - : endianness(serializer.endianness), data(serializer.data), size(serializer.size), offset(serializer.offset) + : BaseObj((BaseObj&&)serializer), endianness(serializer.endianness), data(serializer.data), + size(serializer.size), offset(serializer.offset) { serializer.data = nullptr; serializer.size = 0; serializer.offset = 0; } + Serializer(const Serializer& serializer) + : BaseObj(serializer), endianness(serializer.endianness), data(new Byte[serializer.size]), + size(serializer.size), offset(serializer.offset) + { + for (N i = 0; i < serializer.size; ++i) + data[i] = serializer.data[i]; + } + + Serializer& operator=(Serializer&& serializer) noexcept + { + if (this == &serializer) + return *this; + + BaseObj::operator=((Serializer&&)serializer); + + endianness = serializer.endianness; + delete[] data; + data = serializer.data; + size = serializer.size; + offset = serializer.offset; + + serializer.data = nullptr; + serializer.size = 0; + serializer.offset = 0; + + return *this; + } + Serializer& operator=(const Serializer& serializer) { if (this == &serializer) return *this; + BaseObj::operator=(serializer); + endianness = serializer.endianness; delete[] data; @@ -89,24 +119,6 @@ namespace ehs return *this; } - Serializer& operator=(Serializer&& serializer) noexcept - { - if (this == &serializer) - return *this; - - endianness = serializer.endianness; - delete[] data; - data = serializer.data; - size = serializer.size; - offset = serializer.offset; - - serializer.data = nullptr; - serializer.size = 0; - serializer.offset = 0; - - return *this; - } - bool operator==(const Serializer& in) const { if (size != in.size) diff --git a/include/Str.h b/include/Str.h index f3fb27b..3f91b7f 100644 --- a/include/Str.h +++ b/include/Str.h @@ -1,6 +1,7 @@ #pragma once #include "Types.h" +#include "BaseObj.h" #include "Util.h" #include "Vector.h" @@ -24,7 +25,7 @@ namespace ehs /// @tparam T The character's data type to use. /// @tparam N The number data type to use. template - class Str + class Str : public BaseObj { private: N size; @@ -41,6 +42,7 @@ namespace ehs Str() : size(0), data(nullptr) { + AddType("Str"); } /// Initializes members with given C-style string. @@ -54,6 +56,8 @@ namespace ehs Util::Copy(data, str, Size(true)); data[this->size] = 0; + + AddType("Str"); } /// Initializes members with given C-style string. @@ -66,6 +70,8 @@ namespace ehs Util::Copy(data, str, Size(true)); data[size] = 0; + + AddType("Str"); } /// Initializes string with the given size. @@ -74,33 +80,54 @@ namespace ehs : size(size), data(new T[size + 1]) { data[size] = 0; + + AddType("Str"); + } + + Str(Str&& str) noexcept + : BaseObj((BaseObj&&)str), size(str.size), data(str.data) + { + str.size = 0; + str.data = nullptr; } /// Copies all members from the given string object. /// @param [in] str The string object to copy from. Str(const Str& str) - : size(str.size), data(new T[size + 1]) + : BaseObj(str), size(str.size), data(new T[size + 1]) { Util::Copy(data, str.data, Size(true)); data[size] = 0; } - Str(Str&& str) noexcept - : size(str.size), data(str.data) - { - str.size = 0; - str.data = nullptr; - } + Str& operator=(Str&& str) noexcept + { + if (this == &str) + return *this; + + BaseObj::operator=((BaseObj&&)str); + + size = str.size; + delete[] data; + data = str.data; + + str.size = 0; + str.data = nullptr; + + return *this; + } /// Copies all members from the given string object. /// @param [in] str The string object to copy from. /// @returns The string that has been assigned to. - Str& operator=(const Str& str) + Str& operator=(const Str& str) { if (&str == this) return *this; + BaseObj::operator=(str); + size = str.size; delete[] data; @@ -111,21 +138,6 @@ namespace ehs return *this; } - Str& operator=(Str&& str) noexcept - { - if (this == &str) - return *this; - - size = str.size; - delete[] data; - data = str.data; - - str.size = 0; - str.data = nullptr; - - return *this; - } - /// Copies the given C-style string and retrieves the size. /// @param [in] str The C-style string to copy from. /// @returns The string object that has been assigned to. @@ -1823,39 +1835,39 @@ namespace ehs typedef Str Str_8; } -template -bool operator==(const T* const first, const lwe::Str& second) +template +bool operator==(const T* const first, const ehs::Str& second) { - N inSize = lwe::Str::Len(first); + N inSize = ehs::Str::Len(first); if (second.Size() != inSize) return false; - return lwe::Util::IsEqual(first, second, second.Size(true)); + return ehs::Util::IsEqual(first, second, second.Size(true)); } -template -bool operator!=(const T* const first, const lwe::Str& second) +template +bool operator!=(const T* const first, const ehs::Str& second) { - N inSize = lwe::Str::Len(first); + N inSize = ehs::Str::Len(first); if (second.Size() != inSize) return true; - return !lwe::Util::IsEqual(first, second, second.Size(true)); + return !ehs::Util::IsEqual(first, second, second.Size(true)); } /// Concatenates a C-style string with a string. /// @param [in] first The given C-style string. /// @param [in] second The given string. /// @returns The result. -template -lwe::Str operator+(const T* const first, const lwe::Str& second) +template +ehs::Str operator+(const T* const first, const ehs::Str& second) { - N inSize = lwe::Str::Len(first); + N inSize = ehs::Str::Len(first); - lwe::Str result(inSize + second.Size()); + ehs::Str result(inSize + second.Size()); - lwe::Util::Copy(result, first, inSize * sizeof(T)); - lwe::Util::Copy(&result[inSize], &second[0], second.Size(true)); + ehs::Util::Copy(result, first, inSize * sizeof(T)); + ehs::Util::Copy(&result[inSize], &second[0], second.Size(true)); result[inSize + second.Size()] = 0; diff --git a/include/Type.h b/include/Type.h index a5286a3..5549271 100644 --- a/include/Type.h +++ b/include/Type.h @@ -1,47 +1,55 @@ #pragma once -#include "EHS.h" -#include "Str.h" +#include "Types.h" +#include "Util.h" namespace ehs { class Type { private: + friend class BaseObj; + + UInt_64 size; + const Char_8* id; UInt_64 hashId; - Str_8 id; public: Type(); - Type(Str_8 id); + explicit Type(const Char_8* id); + + Type(Type&& type) noexcept = default; Type(const Type& type) = default; - Type(Type&& type) noexcept; + Type& operator=(Type&& type) noexcept = default; - Type& operator=(const Type& type); - - Type& operator=(Type&& type) noexcept; - - bool operator!() const; + Type& operator=(const Type& type) = default; bool operator==(const Type& type) const; bool operator!=(const Type& type) const; - bool operator==(const UInt_64 hashId) const; + bool operator==(UInt_64 inHashId) const; - bool operator!=(const UInt_64 hashId) const; + bool operator!=(UInt_64 inHashId) const; - bool operator==(const Str_8& type) const; + bool operator==(const Char_8* inStr) const; - bool operator!=(const Str_8& type) const; + bool operator!=(const Char_8* inStr) const; + + UInt_64 GetSize() const; + + const Char_8* GetId() const; UInt_64 GetHashId() const; - Str_8 GetId() const; - bool IsValid() const; + + private: + static UInt_64 CalcSize(const Char_8* id); + + static UInt_64 GenHash(const Char_8* id, UInt_64 size); }; } \ No newline at end of file diff --git a/include/Vector.h b/include/Vector.h index 3546ecd..1c9192e 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -1,12 +1,12 @@ #pragma once +#include "BaseObj.h" #include "Types.h" +#include "Util.h" #include #include -#include "Util.h" - namespace ehs { /// An array with extra memory pre-allocated for fast pushes. @@ -14,7 +14,7 @@ namespace ehs /// @tparam N Number data type to use. /// @note If extra memory is set to five then each time that memory is filled it will add five extra. template - class Vector + class Vector : public BaseObj { protected: N rawSize; @@ -24,7 +24,7 @@ namespace ehs public: /// Frees any data created on the heap. - ~Vector() + ~Vector() override { delete[] data; } @@ -33,6 +33,7 @@ namespace ehs Vector() : rawSize(0), size(0), stride(5), data(nullptr) { + AddType("Vector"); } /// Initializes members for pre-allocated memory to write to later. @@ -41,14 +42,17 @@ namespace ehs Vector(const N size, const N stride) : rawSize(size + stride), size(size), stride(stride), data(new T[rawSize]) { + AddType("Vector"); } /// Initializes this vector with an initializer list object. /// @param [in] list The given initializer list. /// @param [in] stride The extra amount of memory to allocate. Vector(std::initializer_list list, const N stride = 5) - : rawSize(0), size(list.size()), stride(stride), data(nullptr) + : rawSize(0), size(list.size()), stride(stride), data(nullptr) { + AddType("Vector"); + if (stride) { rawSize = list.size() / stride * stride; @@ -74,6 +78,8 @@ namespace ehs Vector(const T* data, const N size, const N stride) : rawSize(0), size(size), stride(stride), data(nullptr) { + AddType("Vector"); + if (stride) { rawSize = size / stride * stride; @@ -94,14 +100,14 @@ namespace ehs /// Copies all members from the given vector object. /// @param [in] vec The vector object to copy from. Vector(const Vector& vec) - : rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(new T[rawSize]) + : BaseObj(vec), rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(new T[rawSize]) { for (N i = 0; i < size; ++i) data[i] = vec.data[i]; } Vector(Vector&& vec) noexcept - : rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(vec.data) + : BaseObj((BaseObj&&)vec), rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(vec.data) { vec.rawSize = 0; vec.size = 0; @@ -117,6 +123,8 @@ namespace ehs if (this == &vec) return *this; + BaseObj::operator=(vec); + rawSize = vec.rawSize; size = vec.size; stride = vec.stride; @@ -135,6 +143,8 @@ namespace ehs if (this == &vec) return *this; + BaseObj::operator=((BaseObj&&)vec); + rawSize = vec.rawSize; size = vec.size; stride = vec.stride; @@ -268,9 +278,12 @@ namespace ehs /// @param [in] dstOffset The offset index to copy the given C-style array to. /// @param [in] src The given C-style array. /// @param [in] size The size from the given C-style array to copy. - void Copy(const N dstOffset, const T* src, const N size) + void Copy(const N dstOffset, const T* src, const N inSize) { - for (N i = 0; i < size; ++i) + if (dstOffset + inSize > size) + return; + + for (N i = 0; i < inSize; ++i) data[i + dstOffset] = src[i]; } diff --git a/include/io/FontAtlas.h b/include/io/FontAtlas.h index 26f7fee..9f7fe68 100644 --- a/include/io/FontAtlas.h +++ b/include/io/FontAtlas.h @@ -31,7 +31,7 @@ namespace ehs UInt_64 GetGlyphScale() const; - Glyph GetGlyph(const Char_32 code) const; + Glyph GetGlyph(Char_32 code) const; Vec2_f CalculateSize(const Str_8& text) const; @@ -41,8 +41,6 @@ namespace ehs UInt_64 CalculateIndexAtPoint(const Str_8& text, const Vec2_f& point) const; - Mesh Generate(const Anchor anchor, const Str_8& text) const; - - FontAtlas* Clone() const override; + Mesh Generate(Anchor anchor, const Str_8& text) const; }; } \ No newline at end of file diff --git a/include/io/audio/Audio.h b/include/io/audio/Audio.h index a379d5a..dd6a141 100644 --- a/include/io/audio/Audio.h +++ b/include/io/audio/Audio.h @@ -1,6 +1,7 @@ #pragma once -#include "EHS.h" +#include "Types.h" +#include "BaseObj.h" #include "DataType.h" #include "Str.h" #include "Serializer.h" @@ -10,10 +11,12 @@ namespace ehs { - class Audio : public Resource + class Audio : public BaseObj { private: static Array codecs; + UInt_64 hashId; + Str_8 id; UInt_64 sampleRate; DataType dataType; UInt_8 byteDepth; @@ -24,29 +27,31 @@ namespace ehs Byte* peak; public: - static bool HasCodec(const UInt_64 hashExt); + static bool HasCodec(UInt_64 hashExt); static bool HasCodec(const Str_8& ext); static bool AddCodec(AudioCodec codec); - static const AudioCodec* GetCodec(const UInt_64 hashExt); + static const AudioCodec* GetCodec(UInt_64 hashExt); static const AudioCodec* GetCodec(const Str_8& ext); - ~Audio() override; + ~Audio(); Audio(); - Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames, const Byte* const data); + Audio(Str_8 id); - Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Serializer& data); + Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames, const Byte* data); - Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Vector& data); + Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Serializer& data); - Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Array& data); + Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Vector& data); - Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames); + Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Array& data); + + Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames); Audio(Audio&& audio) noexcept; @@ -60,6 +65,14 @@ namespace ehs operator Byte*(); + void Release(); + + UInt_64 GetHashId() const; + + void SetId(Str_8 newId); + + Str_8 GetId() const; + UInt_64 GetSampleRate() const; DataType GetDataType() const; @@ -78,23 +91,23 @@ namespace ehs float GetLength() const; - Array FrameAsMono(const UInt_64 frameIndex) const; + Array FrameAsMono(UInt_64 frameIndex) const; - Array FrameAsStereo(const UInt_64 frameIndex) const; + Array FrameAsStereo(UInt_64 frameIndex) const; - Array FrameAsFive_One(const UInt_64 frameIndex) const; + Array FrameAsFive_One(UInt_64 frameIndex) const; - Array FrameAsSeven_One(const UInt_64 frameIndex) const; + Array FrameAsSeven_One(UInt_64 frameIndex) const; - SInt_8 SampleAsSInt_8(const UInt_64 sampleIndex) const; + SInt_8 SampleAsSInt_8(UInt_64 sampleIndex) const; - SInt_16 SampleAsSInt_16(const UInt_64 sampleIndex) const; + SInt_16 SampleAsSInt_16(UInt_64 sampleIndex) const; - float SampleAsFloat(const UInt_64 sampleIndex) const; + float SampleAsFloat(UInt_64 sampleIndex) const; - SInt_32 SampleAsSInt_32(const UInt_64 sampleIndex) const; + SInt_32 SampleAsSInt_32(UInt_64 sampleIndex) const; - SInt_64 SampleAsSInt_64(const UInt_64 sampleIndex) const; + SInt_64 SampleAsSInt_64(UInt_64 sampleIndex) const; SInt_8 PeakAsSInt_8() const; @@ -106,17 +119,17 @@ namespace ehs SInt_64 PeakAsSInt_64() const; - void SetPeak(const UInt_64 size, const Byte* newPeak); + void SetPeak(UInt_64 size, const Byte* newPeak); const Byte* GetPeak() const; - void ToDataType(const DataType newDataType); + void ToDataType(DataType newDataType); - Audio GetAsDataType(const DataType newDataType) const; + Audio GetAsDataType(DataType newDataType) const; - void ToChannels(const UInt_8 newChannels); + void ToChannels(UInt_8 newChannels); - Audio GetAsChannels(const UInt_8 newChannels) const; + Audio GetAsChannels(UInt_8 newChannels) const; bool ToFile(const Str_8& filePath) const; @@ -124,32 +137,32 @@ namespace ehs static Audio* FromFile_Heap(const Str_8& filePath); - static Audio FromFile(const Str_8& filePath, const DataType required); + static Audio FromFile(const Str_8& filePath, DataType required); - static Audio* FromFile_Heap(const Str_8& filePath, const DataType required); + static Audio* FromFile_Heap(const Str_8& filePath, DataType required); - static Audio FromData(const Str_8& ext, const Str_8& id, Serializer& data); + static Audio FromData(Str_8 id, const Str_8& ext, Serializer& data); private: - void ToMono(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void ToMono(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Mono_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Mono_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Five_One_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Five_One_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Seven_One_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Seven_One_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Mono_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Mono_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Stereo_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Stereo_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Seven_One_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Seven_One_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Mono_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Mono_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Stereo_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Stereo_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; - void Five_One_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const; + void Five_One_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; // To SInt_8 void SInt_16_to_SInt_8(Byte* newData, Byte* newPeak) const; diff --git a/include/io/img/Img.h b/include/io/img/Img.h index e63a5dd..4ee6dab 100644 --- a/include/io/img/Img.h +++ b/include/io/img/Img.h @@ -1,6 +1,7 @@ #pragma once -#include "EHS.h" +#include "Types.h" +#include "BaseObj.h" #include "Str.h" #include "ImgCodec.h" @@ -12,12 +13,14 @@ namespace ehs NEAREST_NEIGHBOR }; - class Img + class Img : public BaseObj { private: static Array codecs; protected: + UInt_64 hashId; + Str_8 id; UInt_8 bitDepth; UInt_8 channels; UInt_64 width; @@ -40,9 +43,11 @@ namespace ehs Img(); - Img(UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height, const Byte* data); + Img(Str_8 id); - Img(UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height); + Img(Str_8 id, UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height, const Byte* data); + + Img(Str_8 id, UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height); Img(Img&& img) noexcept; @@ -58,6 +63,12 @@ namespace ehs void Release(); + UInt_64 GetHashId() const; + + void SetId(Str_8 newId); + + Str_8 GetId() const; + UInt_8 BitDepth() const; UInt_8 Channels() const; @@ -120,7 +131,7 @@ namespace ehs static Img* FromFile_Heap(const Str_8& filePath); - static Img FromData(const Str_8& ext, Serializer& data); + static Img FromData(Str_8 id, const Str_8& ext, Serializer& data); private: Img GetNearestNeighbor(UInt_64 newWidth, UInt_64 newHeight) const; diff --git a/include/io/model/Mesh.h b/include/io/model/Mesh.h index 90b5938..4924083 100644 --- a/include/io/model/Mesh.h +++ b/include/io/model/Mesh.h @@ -3,6 +3,7 @@ #include "EHS.h" #include "Array.h" #include "Vertex.h" +#include "BaseObj.h" namespace ehs { @@ -38,15 +39,13 @@ namespace ehs 1 }); - class Mesh : public Resource + class Mesh final : public BaseObj { protected: + UInt_64 hashId; + Str_8 id; Array vertices; Array indices; - GpuBuffer srcVertBuffer; - GpuBuffer dstVertBuffer; - GpuBuffer srcIndBuffer; - GpuBuffer dstIndBuffer; public: Mesh(); @@ -55,8 +54,6 @@ namespace ehs Mesh(Str_8 id, Array vertices); - Mesh(Str_8 id); - Mesh(Mesh&& mesh) noexcept; Mesh(const Mesh& mesh); @@ -65,19 +62,13 @@ namespace ehs Mesh& operator=(const Mesh& mesh); - bool UploadToGpu(GpuCmdBuffer* cmdBuffer) override; + void Release(); - bool PostGpuUpload() override; + UInt_64 GetHashId() const; - bool HasPostGpuUploaded() const override; + void SetId(Str_8 newId); - bool ReleaseFromGpu() override; - - bool IsUploaded() const override; - - void Bind(GpuCmdBuffer* cmdBuffer); - - void Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances = 1); + Str_8 GetId() const; void SetVertices(const Array& newVertices); diff --git a/include/io/model/Model.h b/include/io/model/Model.h index af0cbe2..bc64ab1 100644 --- a/include/io/model/Model.h +++ b/include/io/model/Model.h @@ -14,9 +14,11 @@ namespace ehs EHM }; - class Model : public Resource + class Model : public BaseObj { protected: + UInt_64 hashId; + Str_8 id; Array meshes; Bone skeleton; Array animations; @@ -40,29 +42,27 @@ namespace ehs Model& operator=(const Model& model) = default; - bool UploadToGpu(GpuCmdBuffer* cmdBuffer) override; + void Release(); - bool PostGpuUpload() override; + UInt_64 GetHashId() const; - bool ReleaseFromGpu() override; + void SetId(Str_8 newId); - bool IsUploaded() const override; - - void Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances = 1); + Str_8 GetId() const; Array GetMeshes() const; Array& GetMeshes(); - Mesh* GetMesh(const UInt_64 hashId); + Mesh* GetMesh(UInt_64 inHashId); - Mesh* GetMesh(const Str_8& id); + Mesh* GetMesh(const Str_8& inId); Bone GetSkeleton() const; Bone& GetSkeleton(); - Animation* GetAnimation(const UInt_64 hashId); + Animation* GetAnimation(UInt_64 inHashId); Array GetAnimations() const; @@ -70,7 +70,7 @@ namespace ehs void Calculate(); - void Export(const Str_8& filePath, const ModelEncoding encoding); + void Export(const Str_8& filePath, ModelEncoding encoding); private: void ToEHM(File& file); diff --git a/include/io/model/Vertex.h b/include/io/model/Vertex.h index 6081a69..9a68cc9 100644 --- a/include/io/model/Vertex.h +++ b/include/io/model/Vertex.h @@ -1,6 +1,7 @@ #pragma once #include "EHS.h" +#include "Vec4.h" #include "Vec3.h" #include "Vec2.h" #include "Color4.h" diff --git a/include/io/socket/Comms.h b/include/io/socket/Comms.h index 3f1d316..e132399 100644 --- a/include/io/socket/Comms.h +++ b/include/io/socket/Comms.h @@ -19,6 +19,8 @@ namespace ehs class Comms : public BaseObj { private: + friend class Endpoint; + static const Version ver; static const UInt_64 internalSys; static const UInt_64 connectOp; diff --git a/include/io/socket/Endpoint.h b/include/io/socket/Endpoint.h index 63c9f81..693e97c 100644 --- a/include/io/socket/Endpoint.h +++ b/include/io/socket/Endpoint.h @@ -17,7 +17,7 @@ namespace ehs class Endpoint : public BaseObj { private: - Socket hdl; + Comms* owner; EndDisp disposition; Status status; Architecture arch; @@ -40,10 +40,10 @@ namespace ehs public: Endpoint(); - Endpoint(const Socket hdl, const EndDisp disposition, const Architecture arch, const Str_8& id, + Endpoint(Comms* owner, const EndDisp disposition, const Architecture arch, const Str_8& id, const AddrType& type, const Str_8& address, const UInt_16 port); - Endpoint(const Socket hdl, const AddrType& type, const Str_8& address, const UInt_16 port); + Endpoint(Comms* owner, const AddrType& type, const Str_8& address, const UInt_16 port); Endpoint(const Endpoint& end); diff --git a/src/BaseObj.cpp b/src/BaseObj.cpp index 2030b46..f6569d6 100644 --- a/src/BaseObj.cpp +++ b/src/BaseObj.cpp @@ -4,128 +4,151 @@ namespace ehs { BaseObj::~BaseObj() { + delete[] hierarchy; } - BaseObj::BaseObj() - : parent(nullptr) - { - AddType("BaseObj"); - } + BaseObj::BaseObj() + : hierarchy(nullptr), hierarchySize(0) + { + AddType("BaseObj"); + } - BaseObj::BaseObj(const BaseObj& base) - : hierarchy(base.hierarchy), parent(nullptr) - { - } + BaseObj::BaseObj(BaseObj&& base) noexcept + : hierarchy(base.hierarchy), hierarchySize(base.hierarchySize) + { + base.hierarchy = nullptr; + base.hierarchySize = 0; + } - BaseObj::BaseObj(BaseObj&& base) noexcept - : hierarchy(std::move(base.hierarchy)), parent(base.parent) - { - base.hierarchy = Array(); - base.parent = nullptr; - } + BaseObj::BaseObj(const BaseObj& base) + : hierarchy(new Type[base.hierarchySize]), hierarchySize(base.hierarchySize) + { + for (UInt_64 i = 0; i < hierarchySize; i++) + hierarchy[i] = base.hierarchy[i]; + } - BaseObj& BaseObj::operator=(const BaseObj& base) - { - if (this == &base) - return *this; + BaseObj& BaseObj::operator=(BaseObj&& base) noexcept + { + if (this == &base) + return *this; + + delete[] hierarchy; hierarchy = base.hierarchy; - parent = nullptr; + hierarchySize = base.hierarchySize; - return *this; - } + base.hierarchy = nullptr; + base.hierarchySize = 0; - BaseObj& BaseObj::operator=(BaseObj&& base) noexcept - { - if (this == &base) - return *this; + return *this; + } - hierarchy = std::move(base.hierarchy); - parent = base.parent; + BaseObj& BaseObj::operator=(const BaseObj& base) + { + if (this == &base) + return *this; - base.hierarchy = Array(); - base.parent = nullptr; + delete[] hierarchy; - return *this; - } + hierarchy = new Type[base.hierarchySize]; + for (UInt_64 i = 0; i < base.hierarchySize; i++) + hierarchy[i] = base.hierarchy[i]; - bool BaseObj::operator!() const - { - return IsValid(); - } + hierarchySize = base.hierarchySize; - bool BaseObj::operator==(const BaseObj& base) const - { - return hierarchy == base.hierarchy; - } + return *this; + } - bool BaseObj::operator!=(const BaseObj& base) const - { - return hierarchy != base.hierarchy; - } + bool BaseObj::operator==(const BaseObj& base) const + { + if (hierarchySize != base.hierarchySize) + return false; - bool BaseObj::HasType(const Str_8& type) const - { - return HasType(type.Hash_64()); - } + for (UInt_64 i = 0; i < hierarchySize; i++) + if (hierarchy[i] != base.hierarchy[i]) + return false; - bool BaseObj::AddType(Str_8 type) - { - if (HasType(type)) - return false; + return true; + } - hierarchy.Push(std::move(type)); + bool BaseObj::operator!=(const BaseObj& base) const + { + if (hierarchySize != base.hierarchySize) + return true; - return true; - } + for (UInt_64 i = 0; i < hierarchySize; i++) + if (hierarchy[i] != base.hierarchy[i]) + return true; - Type BaseObj::GetType() const - { - return hierarchy[hierarchy.End()]; - } + return false; + } - Type BaseObj::GetType(const Str_8& type) const - { - return GetType(type.Hash_64()); - } + const Type* BaseObj::GetHierarchy() const + { + return hierarchy; + } - const Char_8* BaseObj::GetTypeId() const - { - return GetType().GetId(); - } + UInt_64 BaseObj::GetHierarchySize() const + { + return hierarchySize; + } + + bool BaseObj::HasType(UInt_64 typeHashId) const + { + for (UInt_64 i = 0; i < hierarchySize; i++) + if (hierarchy[i] == typeHashId) + return true; + + return false; + } + + bool BaseObj::HasType(const Char_8* typeId) const + { + return HasType(Type::GenHash(typeId, Type::CalcSize(typeId))); + } + + Type BaseObj::GetType() const + { + return hierarchy[hierarchySize - 1]; + } + + UInt_64 BaseObj::GetTypeIdSize() const + { + return hierarchy[hierarchySize - 1].GetSize(); + } + + const Char_8* BaseObj::GetTypeId() const + { + return hierarchy[hierarchySize - 1].GetId(); + } UInt_64 BaseObj::GetTypeHashId() const - { - return GetType().GetHashId(); - } + { + return hierarchy[hierarchySize - 1].GetHashId(); + } - const Array& BaseObj::GetHierarchy() const - { - return hierarchy; - } - - void BaseObj::SetParent(BaseObj* newParent) - { - parent = newParent; - } - - BaseObj* BaseObj::GetParent() - { - return parent; - } - - BaseObj* BaseObj::GetParent(const Str_8& type) - { - return GetParent(type.Hash_64()); - } - - BaseObj* BaseObj::Clone() const - { + BaseObj* BaseObj::Clone() const + { return new BaseObj(*this); - } + } - bool BaseObj::IsValid() const - { - return hierarchy.Size(); - } + void BaseObj::AddType(const Char_8* const id) + { + Type newType(id); + + for (UInt_64 i = 0; i < hierarchySize; i++) + if (hierarchy[i] == newType) + return; + + Type* result = new Type[hierarchySize + 1]; + + result[0] = newType; + + for (UInt_64 i = 1; i < hierarchySize; i++) + result[i] = hierarchy[i]; + + hierarchySize++; + delete[] hierarchy; + hierarchy = result; + } } \ No newline at end of file diff --git a/src/EHS.cpp b/src/EHS.cpp index a782b87..031b2c0 100644 --- a/src/EHS.cpp +++ b/src/EHS.cpp @@ -15,15 +15,15 @@ namespace ehs { - constexpr Char_32 name_32[] = U"Lone Wolf Engine"; - constexpr Char_16 name_16[] = L"Lone Wolf Engine"; - constexpr Char_8 name_8[] = "Lone Wolf Engine"; - constexpr Char_32 acronym_32[] = U"LWE"; - constexpr Char_16 acronym_16[] = L"LWE"; - constexpr Char_8 acronym_8[] = "LWE"; - constexpr Char_32 versionId_32[] = U"Beta"; - constexpr Char_16 versionId_16[] = L"Beta"; - constexpr Char_8 versionId_8[] = "Beta"; + constexpr Char_32 name_32[] = U"Event Horizon Suite"; + constexpr Char_16 name_16[] = L"Event Horizon Suite"; + constexpr Char_8 name_8[] = "Event Horizon Suite"; + constexpr Char_32 acronym_32[] = U"EHS"; + constexpr Char_16 acronym_16[] = L"EHS"; + constexpr Char_8 acronym_8[] = "EHS"; + constexpr Char_32 versionId_32[] = U"Release"; + constexpr Char_16 versionId_16[] = L"Release"; + constexpr Char_8 versionId_8[] = "Release"; Str_8 appName; Str_8 appVerId; @@ -94,7 +94,7 @@ namespace ehs return appVer; } - bool DecodeWAV(const lwe::AudioCodec* const codec, lwe::Serializer& in, lwe::Audio* out) + bool DecodeWAV(const ehs::AudioCodec* const codec, ehs::Serializer& in, ehs::Audio* out) { RIFF riff(in); @@ -255,7 +255,7 @@ namespace ehs return true; } - bool EncodeEHA(const lwe::AudioCodec* const codec, lwe::Serializer& out, const lwe::Audio* in) + bool EncodeEHA(const ehs::AudioCodec* const codec, ehs::Serializer& out, const ehs::Audio* in) { Serializer result(codec->GetEndianness()); result.WriteVersion({1, 0, 0}); @@ -277,7 +277,7 @@ namespace ehs return true; } - bool DecodeEHA(const lwe::AudioCodec* const codec, lwe::Serializer& in, lwe::Audio* out) + bool DecodeEHA(const ehs::AudioCodec* const codec, ehs::Serializer& in, ehs::Audio* out) { Version version = in.ReadVersion(); if (version != Version(1, 0, 0)) @@ -303,7 +303,7 @@ namespace ehs return true; } - bool DecodePNG(const lwe::ImgCodec* const codec, lwe::Serializer& in, lwe::Img* out) + bool DecodePNG(const ehs::ImgCodec* const codec, ehs::Serializer& in, ehs::Img* out) { PNG png(out->GetId(), in); @@ -329,7 +329,7 @@ namespace ehs else if (colorType == 6) channels = 4; - *out = Img(out->GetId(), bitDepth, channels, width, height, out->GetAspect(), true); + *out = Img(out->GetId(), bitDepth, channels, width, height); UInt_8 compression = ihdrData->Read(); if (compression) @@ -417,7 +417,7 @@ namespace ehs return true; } - bool EncodeQOI(const lwe::ImgCodec* const codec, lwe::Serializer& out, const lwe::Img* in) + bool EncodeQOI(const ehs::ImgCodec* const codec, ehs::Serializer& out, const ehs::Img* in) { UInt_8 channels = in->Channels(); UInt_64 width = in->Width(); @@ -536,7 +536,7 @@ namespace ehs return true; } - bool DecodeQOI(const lwe::ImgCodec* const codec, lwe::Serializer& in, lwe::Img* out) + bool DecodeQOI(const ehs::ImgCodec* const codec, ehs::Serializer& in, ehs::Img* out) { Str_8 imgType = in.ReadStr(4); if (imgType != "qoif") @@ -555,7 +555,7 @@ namespace ehs UInt_64 size = width * channels * height; - *out = Img(out->GetId(), bitDepth, channels, width, height, out->GetAspect(), true); + *out = Img(out->GetId(), bitDepth, channels, width, height); Byte prevPixel[4] = {0, 0, 0, 255}; @@ -623,45 +623,45 @@ namespace ehs int main() { - lwe::Audio::AddCodec({ + ehs::Audio::AddCodec({ "Waveform Audio", "wav", - lwe::Endianness::LE, + ehs::Endianness::LE, nullptr, - lwe::DecodeWAV + ehs::DecodeWAV }); - lwe::Audio::AddCodec({ + ehs::Audio::AddCodec({ "Event Horizon Audio", "eha", - lwe::Endianness::LE, - lwe::EncodeEHA, - lwe::DecodeEHA + ehs::Endianness::LE, + ehs::EncodeEHA, + ehs::DecodeEHA }); - lwe::Img::AddCodec({ + ehs::Img::AddCodec({ "Portable Network Graphic", "png", - lwe::Endianness::BE, + ehs::Endianness::BE, nullptr, - lwe::DecodePNG + ehs::DecodePNG }); - lwe::Img::AddCodec({ + ehs::Img::AddCodec({ "Quite OK Image", "qoi", - lwe::Endianness::BE, - lwe::EncodeQOI, - lwe::DecodeQOI + ehs::Endianness::BE, + ehs::EncodeQOI, + ehs::DecodeQOI }); - lwe::GarbageCollector::Start(); + ehs::GarbageCollector::Start(); - const lwe::SInt_32 code = Main(&lwe::appName, &lwe::appVerId, &lwe::appVer); + const ehs::SInt_32 code = Main(&ehs::appName, &ehs::appVerId, &ehs::appVer); if (code) - EHS_LOG("Warning", 0, "Executable exited with code #" + lwe::Str_8::FromNum(code) + "."); + EHS_LOG("Warning", 0, "Executable exited with code #" + ehs::Str_8::FromNum(code) + "."); - lwe::GarbageCollector::Stop(); + ehs::GarbageCollector::Stop(); return code; } \ No newline at end of file diff --git a/src/GarbageCollector.cpp b/src/GarbageCollector.cpp index a9a7a46..23c1a36 100644 --- a/src/GarbageCollector.cpp +++ b/src/GarbageCollector.cpp @@ -104,12 +104,6 @@ namespace ehs while (i < garbage.Size()) { - if (garbage[i]->HasType(10756214933709508260ull) && ((GpuDependant*)garbage[i])->GetDependantCount()) // Has type of GpuDependant. - { - ++i; - continue; - } - garbage.Swap(i, garbage.End()); delete garbage.Pop(); } diff --git a/src/HRNG_GCC.asm b/src/HRNG_GCC.asm index f44c880..575446b 100644 --- a/src/HRNG_GCC.asm +++ b/src/HRNG_GCC.asm @@ -1,34 +1,34 @@ -global _ZN3lwe4HRNG16GenerateSeed_u64Ev -global _ZN3lwe4HRNG12Generate_u64Emm -global _ZN3lwe4HRNG12Generate_u64Ev -global _ZN3lwe4HRNG16GenerateSeed_s64Ev -global _ZN3lwe4HRNG12Generate_s64Ell -global _ZN3lwe4HRNG12Generate_s64Ev -global _ZN3lwe4HRNG16GenerateSeed_u32Ev -global _ZN3lwe4HRNG12Generate_u32Ejj -global _ZN3lwe4HRNG12Generate_u32Ev -global _ZN3lwe4HRNG16GenerateSeed_s32Ev -global _ZN3lwe4HRNG12Generate_s32Eii -global _ZN3lwe4HRNG12Generate_s32Ev -global _ZN3lwe4HRNG16GenerateSeed_u16Ev -global _ZN3lwe4HRNG12Generate_u16Ett -global _ZN3lwe4HRNG12Generate_u16Ev -global _ZN3lwe4HRNG16GenerateSeed_s16Ev -global _ZN3lwe4HRNG12Generate_s16Ess -global _ZN3lwe4HRNG12Generate_s16Ev -global _ZN3lwe4HRNG15GenerateSeed_u8Ev -global _ZN3lwe4HRNG11Generate_u8Ehh -global _ZN3lwe4HRNG11Generate_u8Ev -global _ZN3lwe4HRNG15GenerateSeed_s8Ev -global _ZN3lwe4HRNG11Generate_s8Eaa -global _ZN3lwe4HRNG11Generate_s8Ev +global _ZN3ehs4HRNG16GenerateSeed_u64Ev +global _ZN3ehs4HRNG12Generate_u64Emm +global _ZN3ehs4HRNG12Generate_u64Ev +global _ZN3ehs4HRNG16GenerateSeed_s64Ev +global _ZN3ehs4HRNG12Generate_s64Ell +global _ZN3ehs4HRNG12Generate_s64Ev +global _ZN3ehs4HRNG16GenerateSeed_u32Ev +global _ZN3ehs4HRNG12Generate_u32Ejj +global _ZN3ehs4HRNG12Generate_u32Ev +global _ZN3ehs4HRNG16GenerateSeed_s32Ev +global _ZN3ehs4HRNG12Generate_s32Eii +global _ZN3ehs4HRNG12Generate_s32Ev +global _ZN3ehs4HRNG16GenerateSeed_u16Ev +global _ZN3ehs4HRNG12Generate_u16Ett +global _ZN3ehs4HRNG12Generate_u16Ev +global _ZN3ehs4HRNG16GenerateSeed_s16Ev +global _ZN3ehs4HRNG12Generate_s16Ess +global _ZN3ehs4HRNG12Generate_s16Ev +global _ZN3ehs4HRNG15GenerateSeed_u8Ev +global _ZN3ehs4HRNG11Generate_u8Ehh +global _ZN3ehs4HRNG11Generate_u8Ev +global _ZN3ehs4HRNG15GenerateSeed_s8Ev +global _ZN3ehs4HRNG11Generate_s8Eaa +global _ZN3ehs4HRNG11Generate_s8Ev section .text - _ZN3lwe4HRNG16GenerateSeed_u64Ev: + _ZN3ehs4HRNG16GenerateSeed_u64Ev: RDSEED RAX RET - _ZN3lwe4HRNG12Generate_u64Emm: + _ZN3ehs4HRNG12Generate_u64Emm: RDRAND RAX SUB RSI, RDI MOV R8, RSI @@ -38,15 +38,15 @@ section .text ADD RAX, RDI RET - _ZN3lwe4HRNG12Generate_u64Ev: + _ZN3ehs4HRNG12Generate_u64Ev: RDRAND RAX RET - _ZN3lwe4HRNG16GenerateSeed_s64Ev: + _ZN3ehs4HRNG16GenerateSeed_s64Ev: RDSEED RAX RET - _ZN3lwe4HRNG12Generate_s64Ell: + _ZN3ehs4HRNG12Generate_s64Ell: RDRAND RAX SUB RSI, RDI MOV R8, RSI @@ -56,15 +56,15 @@ section .text ADD RAX, RDI RET - _ZN3lwe4HRNG12Generate_s64Ev: + _ZN3ehs4HRNG12Generate_s64Ev: RDRAND RAX RET - _ZN3lwe4HRNG16GenerateSeed_u32Ev: + _ZN3ehs4HRNG16GenerateSeed_u32Ev: RDSEED EAX RET - _ZN3lwe4HRNG12Generate_u32Ejj: + _ZN3ehs4HRNG12Generate_u32Ejj: RDRAND EAX SUB ESI, EDI MOV R8D, ESI @@ -74,15 +74,15 @@ section .text ADD EAX, EDI RET - _ZN3lwe4HRNG12Generate_u32Ev: + _ZN3ehs4HRNG12Generate_u32Ev: RDRAND EAX RET - _ZN3lwe4HRNG16GenerateSeed_s32Ev: + _ZN3ehs4HRNG16GenerateSeed_s32Ev: RDSEED EAX RET - _ZN3lwe4HRNG12Generate_s32Eii: + _ZN3ehs4HRNG12Generate_s32Eii: RDRAND EAX SUB ESI, EDI MOV R8D, ESI @@ -92,15 +92,15 @@ section .text ADD EAX, EDI RET - _ZN3lwe4HRNG12Generate_s32Ev: + _ZN3ehs4HRNG12Generate_s32Ev: RDRAND EAX RET - _ZN3lwe4HRNG16GenerateSeed_u16Ev: + _ZN3ehs4HRNG16GenerateSeed_u16Ev: RDSEED AX RET - _ZN3lwe4HRNG12Generate_u16Ett: + _ZN3ehs4HRNG12Generate_u16Ett: RDRAND AX SUB SI, DI MOV R8W, SI @@ -110,15 +110,15 @@ section .text ADD AX, DI RET - _ZN3lwe4HRNG12Generate_u16Ev: + _ZN3ehs4HRNG12Generate_u16Ev: RDRAND AX RET - _ZN3lwe4HRNG16GenerateSeed_s16Ev: + _ZN3ehs4HRNG16GenerateSeed_s16Ev: RDSEED AX RET - _ZN3lwe4HRNG12Generate_s16Ess: + _ZN3ehs4HRNG12Generate_s16Ess: RDRAND AX SUB SI, DI MOV R8W, SI @@ -128,15 +128,15 @@ section .text ADD AX, DI RET - _ZN3lwe4HRNG12Generate_s16Ev: + _ZN3ehs4HRNG12Generate_s16Ev: RDRAND AX RET - _ZN3lwe4HRNG15GenerateSeed_u8Ev: + _ZN3ehs4HRNG15GenerateSeed_u8Ev: RDSEED AX RET - _ZN3lwe4HRNG11Generate_u8Ehh: + _ZN3ehs4HRNG11Generate_u8Ehh: RDRAND AX XOR AH, AH SUB SIL, DIL @@ -146,15 +146,15 @@ section .text ADD AL, DIL RET - _ZN3lwe4HRNG11Generate_u8Ev: + _ZN3ehs4HRNG11Generate_u8Ev: RDRAND AX RET - _ZN3lwe4HRNG15GenerateSeed_s8Ev: + _ZN3ehs4HRNG15GenerateSeed_s8Ev: RDSEED AX RET - _ZN3lwe4HRNG11Generate_s8Eaa: + _ZN3ehs4HRNG11Generate_s8Eaa: RDRAND AX XOR AH, AH SUB SIL, DIL @@ -164,6 +164,6 @@ section .text ADD AL, DIL RET - _ZN3lwe4HRNG11Generate_s8Ev: + _ZN3ehs4HRNG11Generate_s8Ev: RDRAND AX RET \ No newline at end of file diff --git a/src/HRNG_MSVC.asm b/src/HRNG_MSVC.asm index 10bbcc9..3c2de7f 100644 --- a/src/HRNG_MSVC.asm +++ b/src/HRNG_MSVC.asm @@ -1,34 +1,34 @@ -global ?GenerateSeed_u64@HRNG@lwe@@SA_KXZ -global ?Generate_u64@HRNG@lwe@@SA_K_K0@Z -global ?Generate_u64@HRNG@lwe@@SA_KXZ -global ?GenerateSeed_s64@HRNG@lwe@@SA_JXZ -global ?Generate_s64@HRNG@lwe@@SA_J_J0@Z -global ?Generate_s64@HRNG@lwe@@SA_JXZ -global ?GenerateSeed_u32@HRNG@lwe@@SAIXZ -global ?Generate_u32@HRNG@lwe@@SAIII@Z -global ?Generate_u32@HRNG@lwe@@SAIXZ -global ?GenerateSeed_s32@HRNG@lwe@@SAHXZ -global ?Generate_s32@HRNG@lwe@@SAHHH@Z -global ?Generate_s32@HRNG@lwe@@SAHXZ -global ?GenerateSeed_u16@HRNG@lwe@@SAIXZ -global ?Generate_u16@HRNG@lwe@@SAGGG@Z -global ?Generate_u16@HRNG@lwe@@SAGXZ -global ?GenerateSeed_s16@HRNG@lwe@@SAFXZ -global ?Generate_s16@HRNG@lwe@@SAFFF@Z -global ?Generate_s16@HRNG@lwe@@SAFXZ -global ?GenerateSeed_u8@HRNG@lwe@@SAEXZ -global ?Generate_u8@HRNG@lwe@@SAEEE@Z -global ?Generate_u8@HRNG@lwe@@SAEXZ -global ?GenerateSeed_s8@HRNG@lwe@@SACXZ -global ?Generate_s8@HRNG@lwe@@SACCC@Z -global ?Generate_s8@HRNG@lwe@@SACXZ +global ?GenerateSeed_u64@HRNG@ehs@@SA_KXZ +global ?Generate_u64@HRNG@ehs@@SA_K_K0@Z +global ?Generate_u64@HRNG@ehs@@SA_KXZ +global ?GenerateSeed_s64@HRNG@ehs@@SA_JXZ +global ?Generate_s64@HRNG@ehs@@SA_J_J0@Z +global ?Generate_s64@HRNG@ehs@@SA_JXZ +global ?GenerateSeed_u32@HRNG@ehs@@SAIXZ +global ?Generate_u32@HRNG@ehs@@SAIII@Z +global ?Generate_u32@HRNG@ehs@@SAIXZ +global ?GenerateSeed_s32@HRNG@ehs@@SAHXZ +global ?Generate_s32@HRNG@ehs@@SAHHH@Z +global ?Generate_s32@HRNG@ehs@@SAHXZ +global ?GenerateSeed_u16@HRNG@ehs@@SAIXZ +global ?Generate_u16@HRNG@ehs@@SAGGG@Z +global ?Generate_u16@HRNG@ehs@@SAGXZ +global ?GenerateSeed_s16@HRNG@ehs@@SAFXZ +global ?Generate_s16@HRNG@ehs@@SAFFF@Z +global ?Generate_s16@HRNG@ehs@@SAFXZ +global ?GenerateSeed_u8@HRNG@ehs@@SAEXZ +global ?Generate_u8@HRNG@ehs@@SAEEE@Z +global ?Generate_u8@HRNG@ehs@@SAEXZ +global ?GenerateSeed_s8@HRNG@ehs@@SACXZ +global ?Generate_s8@HRNG@ehs@@SACCC@Z +global ?Generate_s8@HRNG@ehs@@SACXZ section .text - ?GenerateSeed_u64@HRNG@lwe@@SA_KXZ: + ?GenerateSeed_u64@HRNG@ehs@@SA_KXZ: RDSEED RAX RET - ?Generate_u64@HRNG@lwe@@SA_K_K0@Z: + ?Generate_u64@HRNG@ehs@@SA_K_K0@Z: RDRAND RAX MOV R8, RDX SUB R8, RCX @@ -38,15 +38,15 @@ section .text ADD RAX, RCX RET - ?Generate_u64@HRNG@lwe@@SA_KXZ: + ?Generate_u64@HRNG@ehs@@SA_KXZ: RDRAND RAX RET - ?GenerateSeed_s64@HRNG@lwe@@SA_JXZ: + ?GenerateSeed_s64@HRNG@ehs@@SA_JXZ: RDSEED RAX RET - ?Generate_s64@HRNG@lwe@@SA_J_J0@Z: + ?Generate_s64@HRNG@ehs@@SA_J_J0@Z: RDRAND RAX MOV R8, RDX SUB R8, RCX @@ -56,15 +56,15 @@ section .text ADD RAX, RCX RET - ?Generate_s64@HRNG@lwe@@SA_JXZ: + ?Generate_s64@HRNG@ehs@@SA_JXZ: RDRAND RAX RET - ?GenerateSeed_u32@HRNG@lwe@@SAIXZ: + ?GenerateSeed_u32@HRNG@ehs@@SAIXZ: RDSEED EAX RET - ?Generate_u32@HRNG@lwe@@SAIII@Z: + ?Generate_u32@HRNG@ehs@@SAIII@Z: RDRAND EAX MOV R8D, EDX SUB R8D, ECX @@ -74,15 +74,15 @@ section .text ADD EAX, ECX RET - ?Generate_u32@HRNG@lwe@@SAIXZ: + ?Generate_u32@HRNG@ehs@@SAIXZ: RDRAND EAX RET - ?GenerateSeed_s32@HRNG@lwe@@SAHXZ: + ?GenerateSeed_s32@HRNG@ehs@@SAHXZ: RDSEED EAX RET - ?Generate_s32@HRNG@lwe@@SAHHH@Z: + ?Generate_s32@HRNG@ehs@@SAHHH@Z: RDRAND EAX MOV R8D, EDX SUB R8D, ECX @@ -92,15 +92,15 @@ section .text ADD EAX, ECX RET - ?Generate_s32@HRNG@lwe@@SAHXZ: + ?Generate_s32@HRNG@ehs@@SAHXZ: RDRAND EAX RET - ?GenerateSeed_u16@HRNG@lwe@@SAIXZ: + ?GenerateSeed_u16@HRNG@ehs@@SAIXZ: RDSEED AX RET - ?Generate_u16@HRNG@lwe@@SAGGG@Z: + ?Generate_u16@HRNG@ehs@@SAGGG@Z: RDRAND AX MOV R8W, DX SUB R8W, CX @@ -110,15 +110,15 @@ section .text ADD AX, CX RET - ?Generate_u16@HRNG@lwe@@SAGXZ: + ?Generate_u16@HRNG@ehs@@SAGXZ: RDRAND AX RET - ?GenerateSeed_s16@HRNG@lwe@@SAFXZ: + ?GenerateSeed_s16@HRNG@ehs@@SAFXZ: RDSEED AX RET - ?Generate_s16@HRNG@lwe@@SAFFF@Z: + ?Generate_s16@HRNG@ehs@@SAFFF@Z: RDRAND AX MOV R8W, DX SUB R8W, CX @@ -128,15 +128,15 @@ section .text ADD AX, CX RET - ?Generate_s16@HRNG@lwe@@SAFXZ: + ?Generate_s16@HRNG@ehs@@SAFXZ: RDRAND AX RET - ?GenerateSeed_u8@HRNG@lwe@@SAEXZ: + ?GenerateSeed_u8@HRNG@ehs@@SAEXZ: RDSEED AX RET - ?Generate_u8@HRNG@lwe@@SAEEE@Z: + ?Generate_u8@HRNG@ehs@@SAEEE@Z: RDRAND AX MOV R8W, DX SUB R8W, CX @@ -146,15 +146,15 @@ section .text ADD AX, CX RET - ?Generate_u8@HRNG@lwe@@SAEXZ: + ?Generate_u8@HRNG@ehs@@SAEXZ: RDRAND AX RET - ?GenerateSeed_s8@HRNG@lwe@@SACXZ: + ?GenerateSeed_s8@HRNG@ehs@@SACXZ: RDSEED AX RET - ?Generate_s8@HRNG@lwe@@SACCC@Z: + ?Generate_s8@HRNG@ehs@@SACCC@Z: RDRAND AX MOV R8W, DX SUB R8W, CX @@ -164,6 +164,6 @@ section .text ADD AX, CX RET - ?Generate_s8@HRNG@lwe@@SACXZ: + ?Generate_s8@HRNG@ehs@@SACXZ: RDRAND AX RET \ No newline at end of file diff --git a/src/Math_GCC_AMD64.asm b/src/Math_GCC_AMD64.asm index b08777f..cba840c 100644 --- a/src/Math_GCC_AMD64.asm +++ b/src/Math_GCC_AMD64.asm @@ -1,61 +1,61 @@ -global _ZN3lwe4Math8Sqrt_AVXEf -global _ZN3lwe4Math8Sqrt_AVXEd -global _ZN3lwe4Math8Sqrt_SSEEf -global _ZN3lwe4Math9Sqrt_SSE2Ed -global _ZN3lwe4Math4NearEf -global _ZN3lwe4Math4NearEd -global _ZN3lwe4Math5FloorEf -global _ZN3lwe4Math5FloorEd -global _ZN3lwe4Math4CeilEf -global _ZN3lwe4Math4CeilEd -global _ZN3lwe4Math5TruncEf -global _ZN3lwe4Math5TruncEd +global _ZN3ehs4Math8Sqrt_AVXEf +global _ZN3ehs4Math8Sqrt_AVXEd +global _ZN3ehs4Math8Sqrt_SSEEf +global _ZN3ehs4Math9Sqrt_SSE2Ed +global _ZN3ehs4Math4NearEf +global _ZN3ehs4Math4NearEd +global _ZN3ehs4Math5FloorEf +global _ZN3ehs4Math5FloorEd +global _ZN3ehs4Math4CeilEf +global _ZN3ehs4Math4CeilEd +global _ZN3ehs4Math5TruncEf +global _ZN3ehs4Math5TruncEd section .text - _ZN3lwe4Math8Sqrt_AVXEf: + _ZN3ehs4Math8Sqrt_AVXEf: VSQRTPS XMM0, XMM0 RET - _ZN3lwe4Math8Sqrt_AVXEd: + _ZN3ehs4Math8Sqrt_AVXEd: VSQRTPD XMM0, XMM0 RET - _ZN3lwe4Math8Sqrt_SSEEf: + _ZN3ehs4Math8Sqrt_SSEEf: SQRTPS XMM0, XMM0 RET - _ZN3lwe4Math9Sqrt_SSE2Ed: + _ZN3ehs4Math9Sqrt_SSE2Ed: SQRTPD XMM0, XMM0 RET - _ZN3lwe4Math4NearEf: + _ZN3ehs4Math4NearEf: ROUNDPS XMM0, XMM0, 0 RET - _ZN3lwe4Math4NearEd: + _ZN3ehs4Math4NearEd: ROUNDPD XMM0, XMM0, 0 RET - _ZN3lwe4Math5FloorEf: + _ZN3ehs4Math5FloorEf: ROUNDPS XMM0, XMM0, 1 RET - _ZN3lwe4Math5FloorEd: + _ZN3ehs4Math5FloorEd: ROUNDPD XMM0, XMM0, 1 RET - _ZN3lwe4Math4CeilEf: + _ZN3ehs4Math4CeilEf: ROUNDPS XMM0, XMM0, 2 RET - _ZN3lwe4Math4CeilEd: + _ZN3ehs4Math4CeilEd: ROUNDPD XMM0, XMM0, 2 RET - _ZN3lwe4Math5TruncEf: + _ZN3ehs4Math5TruncEf: ROUNDPS XMM0, XMM0, 3 RET - _ZN3lwe4Math5TruncEd: + _ZN3ehs4Math5TruncEd: ROUNDPD XMM0, XMM0, 3 RET \ No newline at end of file diff --git a/src/Math_MSVC_AMD64.asm b/src/Math_MSVC_AMD64.asm index 19059af..c151e74 100644 --- a/src/Math_MSVC_AMD64.asm +++ b/src/Math_MSVC_AMD64.asm @@ -1,61 +1,61 @@ -global ?Sqrt_AVX@Math@lwe@@CAMM@Z -global ?Sqrt_AVX@Math@lwe@@CANN@Z -global ?Sqrt_SSE@Math@lwe@@CAMM@Z -global ?Sqrt_SSE2@Math@lwe@@CANN@Z -global ?Near@Math@lwe@@SAMM@Z -global ?Near@Math@lwe@@SANN@Z -global ?Floor@Math@lwe@@SAMM@Z -global ?Floor@Math@lwe@@SANN@Z -global ?Ceil@Math@lwe@@SAMM@Z -global ?Ceil@Math@lwe@@SANN@Z -global ?Trunc@Math@lwe@@SAMM@Z -global ?Trunc@Math@lwe@@SANN@Z +global ?Sqrt_AVX@Math@ehs@@CAMM@Z +global ?Sqrt_AVX@Math@ehs@@CANN@Z +global ?Sqrt_SSE@Math@ehs@@CAMM@Z +global ?Sqrt_SSE2@Math@ehs@@CANN@Z +global ?Near@Math@ehs@@SAMM@Z +global ?Near@Math@ehs@@SANN@Z +global ?Floor@Math@ehs@@SAMM@Z +global ?Floor@Math@ehs@@SANN@Z +global ?Ceil@Math@ehs@@SAMM@Z +global ?Ceil@Math@ehs@@SANN@Z +global ?Trunc@Math@ehs@@SAMM@Z +global ?Trunc@Math@ehs@@SANN@Z section .text - ?Sqrt_AVX@Math@lwe@@CAMM@Z: + ?Sqrt_AVX@Math@ehs@@CAMM@Z: VSQRTPS XMM0, XMM0 RET - ?Sqrt_AVX@Math@lwe@@CANN@Z: + ?Sqrt_AVX@Math@ehs@@CANN@Z: VSQRTPD XMM0, XMM0 RET - ?Sqrt_SSE@Math@lwe@@CAMM@Z: + ?Sqrt_SSE@Math@ehs@@CAMM@Z: SQRTPS XMM0, XMM0 RET - ?Sqrt_SSE2@Math@lwe@@CANN@Z: + ?Sqrt_SSE2@Math@ehs@@CANN@Z: SQRTPD XMM0, XMM0 RET - ?Near@Math@lwe@@SAMM@Z: + ?Near@Math@ehs@@SAMM@Z: ROUNDPS XMM0, XMM0, 0 RET - ?Near@Math@lwe@@SANN@Z: + ?Near@Math@ehs@@SANN@Z: ROUNDPD XMM0, XMM0, 0 RET - ?Floor@Math@lwe@@SAMM@Z: + ?Floor@Math@ehs@@SAMM@Z: ROUNDPS XMM0, XMM0, 1 RET - ?Floor@Math@lwe@@SANN@Z: + ?Floor@Math@ehs@@SANN@Z: ROUNDPD XMM0, XMM0, 1 RET - ?Ceil@Math@lwe@@SAMM@Z: + ?Ceil@Math@ehs@@SAMM@Z: ROUNDPS XMM0, XMM0, 2 RET - ?Ceil@Math@lwe@@SANN@Z: + ?Ceil@Math@ehs@@SANN@Z: ROUNDPD XMM0, XMM0, 2 RET - ?Trunc@Math@lwe@@SAMM@Z: + ?Trunc@Math@ehs@@SAMM@Z: ROUNDPS XMM0, XMM0, 3 RET - ?Trunc@Math@lwe@@SANN@Z: + ?Trunc@Math@ehs@@SANN@Z: ROUNDPD XMM0, XMM0, 3 RET \ No newline at end of file diff --git a/src/StrToHash.cpp b/src/StrToHash.cpp index fbdbeb9..4583a2d 100644 --- a/src/StrToHash.cpp +++ b/src/StrToHash.cpp @@ -2,31 +2,31 @@ #include "Str.h" #include "io/Console.h" -lwe::Int_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVer) +ehs::Int_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer) { *appName = "StrToHash"; *appVerId = "Release"; *appVer = {1, 0, 0}; - lwe::Console::Attach(); + ehs::Console::Attach(); - lwe::Vector args = lwe::Console::GetArgs_8(); + ehs::Vector args = ehs::Console::GetArgs_8(); if (args.Size() > 1) { - for (lwe::UInt_64 i = 1; i < args.Size(); ++i) - lwe::Console::Write_8("Result " + lwe::Str_8::FromNum(i) + ": " + lwe::Str_8::FromNum(args[i].Hash_64())); + for (ehs::UInt_64 i = 1; i < args.Size(); ++i) + ehs::Console::Write_8("Result " + ehs::Str_8::FromNum(i) + ": " + ehs::Str_8::FromNum(args[i].Hash_64())); } else { - lwe::Console::Write_8("String: ", false); - lwe::Str_8 in = lwe::Console::Read_8(); - lwe::Console::Write_8("Result: " + lwe::Str_8::FromNum(in.Hash_64())); + ehs::Console::Write_8("String: ", false); + ehs::Str_8 in = ehs::Console::Read_8(); + ehs::Console::Write_8("Result: " + ehs::Str_8::FromNum(in.Hash_64())); - lwe::Console::Read_8(); + ehs::Console::Read_8(); } - lwe::Console::Free(); + ehs::Console::Free(); return 0; } diff --git a/src/Task.cpp b/src/Task.cpp index 2f643eb..02f26f8 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -137,7 +137,7 @@ namespace ehs working = false; available = new Semaphore(0); done = new Semaphore(0); - cbArgs = new Serializer*(new Serializer()); + cbArgs = new Serializer*(new Serializer()); callback = new TaskCb(nullptr); threadArgs = new Serializer(Endianness::LE); diff --git a/src/Type.cpp b/src/Type.cpp index 750dd1f..db6c172 100644 --- a/src/Type.cpp +++ b/src/Type.cpp @@ -2,93 +2,94 @@ namespace ehs { - Type::Type() - : hashId(0) - { - } - - Type::Type(Str_8 id) - : hashId(id.Hash_64()), id(std::move(id)) - { - } - - Type::Type(Type&& type) noexcept - : hashId(type.hashId), id(std::move(type.id)) - { - type.hashId = 0; - } - - Type& Type::operator=(const Type& type) - { - if (this == &type) - return *this; - - hashId = type.hashId; - id = type.id; - - return *this; - } - - Type& Type::operator=(Type&& type) noexcept - { - if (this == &type) - return *this; - - hashId = type.hashId; - id = std::move(type.id); - - type.hashId = 0; - - return *this; - } - - bool Type::operator!() const - { - return IsValid(); - } - - bool Type::operator==(const Type& type) const - { - return hashId == type.hashId; - } - - bool Type::operator!=(const Type& type) const - { - return hashId != type.hashId; - } - - bool Type::operator==(const UInt_64 hashId) const + Type::Type() + : size(0), id(nullptr), hashId(0) { - return this->hashId == hashId; } - bool Type::operator!=(const UInt_64 hashId) const + Type::Type(const Char_8* const id) + : size(CalcSize(id)), id(id), hashId(GenHash(id, size)) { - return this->hashId == hashId; } - bool Type::operator==(const Str_8& type) const - { - return id == type; - } + bool Type::operator==(const Type& type) const + { + return hashId == type.hashId; + } - bool Type::operator!=(const Str_8& type) const - { - return id != type; - } + bool Type::operator!=(const Type& type) const + { + return hashId != type.hashId; + } + + bool Type::operator==(const UInt_64 inHashId) const + { + return hashId == inHashId; + } + + bool Type::operator!=(const UInt_64 inHashId) const + { + return hashId != inHashId; + } + + bool Type::operator==(const Char_8* const inStr) const + { + if (size != CalcSize(inStr)) + return false; + + return Util::IsEqual(id, inStr, size); + } + + bool Type::operator!=(const Char_8* const inStr) const + { + if (size != CalcSize(inStr)) + return true; + + return !Util::IsEqual(id, inStr, size); + } + + UInt_64 Type::GetSize() const + { + return size; + } + + const Char_8* Type::GetId() const + { + return id; + } UInt_64 Type::GetHashId() const { return hashId; } - Str_8 Type::GetId() const + bool Type::IsValid() const { - return id; + return size; } - bool Type::IsValid() const - { - return hashId; - } + UInt_64 Type::CalcSize(const Char_8* const id) + { + UInt_64 result = 0; + + while (id[result]) + result++; + + return result; + } + + UInt_64 Type::GenHash(const Char_8* const id, const UInt_64 size) + { + if (!size) + return 0; + + const Byte* const bytes = (Byte*)id; + + UInt_64 hash = 14695981039346656037ull; + + for (UInt_64 i = 0; i < size; ++i) + hash = (hash ^ bytes[i]) * 1099511628211; + + return hash; + } } \ No newline at end of file diff --git a/src/io/FontAtlas.cpp b/src/io/FontAtlas.cpp index 4a2d179..69b7aaa 100644 --- a/src/io/FontAtlas.cpp +++ b/src/io/FontAtlas.cpp @@ -7,14 +7,11 @@ namespace ehs FontAtlas::FontAtlas() : glyphScale(0) { - AddType("FontAtlas"); } FontAtlas::FontAtlas(const Str_8& filePath) : glyphScale(0) { - AddType("FontAtlas"); - File fontFile(filePath, Mode::READ, Disposition::OPEN); hashId = fontFile.GetName().Hash_64(); @@ -44,7 +41,6 @@ namespace ehs height = fData.Read(); data = new Byte[width * height * (bitDepth / 8) * channels]; fData.ReadArray(data, &size); - aspect = IMG_ASPECT_COLOR; } FontAtlas::FontAtlas(FontAtlas&& fa) noexcept @@ -229,11 +225,6 @@ namespace ehs pos.x += (float)glyph.GetAdvance().x; } - return {"Label", std::move(verts), std::move(indices)}; - } - - FontAtlas* FontAtlas::Clone() const - { - return new FontAtlas(*this); + return {id, std::move(verts), std::move(indices)}; } } \ No newline at end of file diff --git a/src/io/Window_XCB.cpp b/src/io/Window_XCB.cpp index 5cd8323..8926547 100644 --- a/src/io/Window_XCB.cpp +++ b/src/io/Window_XCB.cpp @@ -1,9 +1,11 @@ #include "io/Window_XCB.h" #include "UTF.h" +#include "Vec2.h" #include "io/hid/Keyboard.h" #include "io/hid/Mouse.h" #include "io/Console.h" +#include #include #include #include diff --git a/src/io/audio/Audio.cpp b/src/io/audio/Audio.cpp index fa62147..28e1116 100644 --- a/src/io/audio/Audio.cpp +++ b/src/io/audio/Audio.cpp @@ -51,64 +51,73 @@ namespace ehs } Audio::Audio() - : sampleRate(0), dataType(DataType::FLOAT), byteDepth(ToByteDepth(dataType)), channels(0), frames(0), length(0.0f), - data(nullptr), peak(nullptr) + : hashId(0), sampleRate(0), dataType(DataType::FLOAT), byteDepth(0), channels(0), frames(0), + length(0.0f), data(nullptr), peak(nullptr) { AddType("Audio"); } Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames, const Byte* const data) - : Resource(std::move(id)), dataType(dataType), byteDepth(ToByteDepth(dataType)), sampleRate(sampleRate), + : hashId(id.Hash_64()), id((Str_8&&)id), dataType(dataType), byteDepth(ToByteDepth(dataType)), sampleRate(sampleRate), channels(channels), frames(frames), length((float)frames / (float)sampleRate), data(new Byte[GetSize()]), peak(new Byte[byteDepth]) { - AddType("Audio"); - Util::Copy(this->data, data, GetSize()); + + AddType("Audio"); } Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Serializer& data) - : Resource(std::move(id)), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), + : hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), channels(channels), frames(data.Size() / channels / byteDepth), length((float)frames / (float)sampleRate), data(new Byte[data.Size()]), peak(new Byte[byteDepth]) { - AddType("Audio"); - Util::Copy(this->data, data, data.Size()); + + AddType("Audio"); } Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Vector& data) - : Resource(std::move(id)), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), + : hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), channels(channels), frames(data.Size() / channels / byteDepth), length((float)frames / (float)sampleRate), data(new Byte[data.Size()]), peak(new Byte[byteDepth]) { - AddType("Audio"); - Util::Copy(this->data, data, data.Size()); + + AddType("Audio"); } Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Array& data) - : Resource(std::move(id)), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), + : hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), channels(channels), frames(data.Size() / channels / byteDepth), length((float)frames / (float)sampleRate), data(new Byte[data.Size()]), peak(new Byte[byteDepth]) { - AddType("Audio"); - Util::Copy(this->data, data, data.Size()); + + AddType("Audio"); } Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames) - : Resource(std::move(id)), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), + : hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)), channels(channels), frames(frames), length((float)frames / (float)sampleRate), data(new Byte[GetSize()]), peak(new Byte[byteDepth]) { AddType("Audio"); } + Audio::Audio(Str_8 id) + : hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(0), dataType(DataType::FLOAT), byteDepth(0), channels(0), + frames(0), length(0.0f), data(nullptr), peak(nullptr) + { + AddType("Audio"); + } + Audio::Audio(Audio&& audio) noexcept - : Resource(std::move(audio)), sampleRate(audio.sampleRate), dataType(audio.dataType), byteDepth(audio.byteDepth), - channels(audio.channels), frames(audio.frames), length(audio.length), data(audio.data), peak(audio.peak) + : BaseObj((BaseObj&&)audio), hashId(audio.hashId), id((Str_8&&)id), sampleRate(audio.sampleRate), + dataType(audio.dataType), byteDepth(audio.byteDepth), channels(audio.channels), frames(audio.frames), + length(audio.length), data(audio.data), peak(audio.peak) { + audio.hashId = 0; audio.sampleRate = 0; audio.dataType = DataType::FLOAT; audio.byteDepth = ToByteDepth(audio.dataType); @@ -120,9 +129,9 @@ namespace ehs } Audio::Audio(const Audio& audio) - : Resource(audio), sampleRate(audio.sampleRate), dataType(audio.dataType), byteDepth(audio.byteDepth), - channels(audio.channels), frames(audio.frames), length(audio.length), data(new Byte[GetSize()]), - peak(new Byte[audio.byteDepth]) + : BaseObj(audio), hashId(audio.hashId), id(audio.id), sampleRate(audio.sampleRate), dataType(audio.dataType), + byteDepth(audio.byteDepth), channels(audio.channels), frames(audio.frames), length(audio.length), + data(new Byte[GetSize()]), peak(new Byte[audio.byteDepth]) { Util::Copy(data, audio.data, GetSize()); } @@ -132,15 +141,22 @@ namespace ehs if (this == &audio) return *this; + BaseObj::operator=((BaseObj&&)audio); + + hashId = audio.hashId; + id = (Str_8&&)audio.id; sampleRate = audio.sampleRate; dataType = audio.dataType; byteDepth = audio.byteDepth; channels = audio.channels; frames = audio.frames; length = audio.length; + delete[] data; data = audio.data; + delete[] peak; peak = audio.peak; + audio.hashId = 0; audio.sampleRate = 0; audio.dataType = DataType::FLOAT; audio.byteDepth = ToByteDepth(audio.dataType); @@ -150,8 +166,6 @@ namespace ehs audio.data = nullptr; audio.peak = nullptr; - Resource::operator=(std::move(audio)); - return *this; } @@ -160,6 +174,10 @@ namespace ehs if (this == &audio) return *this; + BaseObj::operator=(audio); + + hashId = audio.hashId; + id = audio.id; sampleRate = audio.sampleRate; dataType = audio.dataType; byteDepth = audio.byteDepth; @@ -168,11 +186,12 @@ namespace ehs frames = audio.frames; delete[] data; - data = new Byte[audio.frames]; + data = new Byte[audio.GetSize()]; + Util::Copy(data, audio.data, audio.GetSize()); - Util::Copy(data, audio.data, frames); - - Resource::operator=(audio); + delete[] peak; + peak = new Byte[audio.byteDepth]; + Util::Copy(peak, audio.peak, audio.byteDepth); return *this; } @@ -187,6 +206,36 @@ namespace ehs return data; } + void Audio::Release() + { + sampleRate = 0; + dataType = DataType::FLOAT; + byteDepth = 0; + channels = 0; + frames = 0; + length = 0.0f; + delete[] data; + data = nullptr; + delete[] peak; + peak = nullptr; + } + + UInt_64 Audio::GetHashId() const + { + return hashId; + } + + void Audio::SetId(Str_8 newId) + { + hashId = newId.Hash_64(); + id = (Str_8&&)newId; + } + + Str_8 Audio::GetId() const + { + return id; + } + UInt_64 Audio::GetSampleRate() const { return sampleRate; @@ -657,7 +706,7 @@ namespace ehs if (!data || newChannels == channels) return; - Byte* result = nullptr; + Byte* result; if (newChannels == 1) { @@ -837,12 +886,12 @@ namespace ehs return false; } - Serializer data; - if (!codec->Encode(data, this)) + Serializer result; + if (!codec->Encode(result, this)) return false; File file(filePath, Mode::WRITE, Disposition::CREATE_PERSISTENT); - file.WriteSerializer_64(data); + file.WriteSerializer_64(result); return true; } @@ -852,7 +901,7 @@ namespace ehs File file(filePath, Mode::READ, Disposition::OPEN); Str_8 ext = file.GetExtension(); - Audio result; + Audio result(file.GetName()); const AudioCodec* codec = GetCodec(ext); if (!codec) @@ -861,8 +910,6 @@ namespace ehs return result; } - result.id = file.GetName(); - Serializer data = file.ReadSerializer_64(codec->GetEndianness(), file.Size()); file.Release(); @@ -887,8 +934,7 @@ namespace ehs return result; } - result = new Audio(); - result->id = file.GetName(); + result = new Audio(file.GetName()); Serializer data = file.ReadSerializer_64(codec->GetEndianness(), file.Size()); @@ -923,9 +969,9 @@ namespace ehs return result; } - Audio Audio::FromData(const Str_8& ext, const Str_8& id, Serializer& data) + Audio Audio::FromData(Str_8 id, const Str_8& ext, Serializer& data) { - Audio result; + Audio result((Str_8&&)id); const AudioCodec* codec = GetCodec(ext); if (!codec) @@ -934,8 +980,6 @@ namespace ehs return result; } - result.id = id; - if (!codec->Decode(data, &result)) return {}; diff --git a/src/io/img/Img.cpp b/src/io/img/Img.cpp index ed2f782..e8614d1 100644 --- a/src/io/img/Img.cpp +++ b/src/io/img/Img.cpp @@ -48,26 +48,36 @@ namespace ehs } Img::Img() - : data(nullptr), bitDepth(0), channels(0), width(0), height(0), size(0) + : hashId(0), data(nullptr), bitDepth(0), channels(0), width(0), height(0), size(0) { + AddType("Img"); } - Img::Img(const UInt_8 bitDepth, const UInt_8 channels, const UInt_64 width, const UInt_64 height, const Byte* const data) - : bitDepth(bitDepth), channels(channels), width(width), height(height), + Img::Img(Str_8 id, const UInt_8 bitDepth, const UInt_8 channels, const UInt_64 width, const UInt_64 height, const Byte* const data) + : hashId(id.Hash_64()), id((Str_8&&)id), bitDepth(bitDepth), channels(channels), width(width), height(height), size(width * (bitDepth / 8) * channels * height), data(new Byte[size]) { Util::Copy(this->data, data, size); + + AddType("Img"); } - Img::Img(const UInt_8 bitDepth, const UInt_8 channels, const UInt_64 width, const UInt_64 height) - : bitDepth(bitDepth), channels(channels), width(width), height(height), + Img::Img(Str_8 id, const UInt_8 bitDepth, const UInt_8 channels, const UInt_64 width, const UInt_64 height) + : hashId(id.Hash_64()), id((Str_8&&)id), bitDepth(bitDepth), channels(channels), width(width), height(height), size(width * (bitDepth / 8) * channels * height), data(new Byte[size]) { + AddType("Img"); + } + + Img::Img(Str_8 id) + : hashId(id.Hash_64()), id((Str_8&&)id), bitDepth(0), channels(0), width(0), height(0), size(0), data(nullptr) + { + AddType("Img"); } Img::Img(Img&& img) noexcept - : bitDepth(img.bitDepth), channels(img.channels), width(img.width), height(img.height), size(img.size), - data(img.data) + : BaseObj((BaseObj&&)img), hashId(img.hashId), id((Str_8&&)img.id), bitDepth(img.bitDepth), + channels(img.channels), width(img.width), height(img.height), size(img.size), data(img.data) { img.bitDepth = 0; img.channels = 0; @@ -78,8 +88,8 @@ namespace ehs } Img::Img(const Img& img) - : bitDepth(img.bitDepth), channels(img.channels), width(img.width), height(img.height), size(img.size), - data(new Byte[img.size]) + : BaseObj(img), hashId(img.hashId), id(img.id), bitDepth(img.bitDepth), channels(img.channels), width(img.width), + height(img.height), size(img.size), data(new Byte[img.size]) { Util::Copy(data, img.data, img.size); } @@ -89,13 +99,14 @@ namespace ehs if (this == &img) return *this; - Release(); + BaseObj::operator=((BaseObj&&)img); bitDepth = img.bitDepth; channels = img.channels; width = img.width; height = img.height; size = img.size; + delete[] data; data = img.data; img.bitDepth = 0; @@ -113,7 +124,7 @@ namespace ehs if (this == &img) return *this; - Release(); + BaseObj::operator=(img); bitDepth = img.bitDepth; channels = img.channels; @@ -139,10 +150,31 @@ namespace ehs void Img::Release() { + bitDepth = 0; + channels = 0; + width = 0; + height = 0; + size = 0; delete[] data; data = nullptr; } + UInt_64 Img::GetHashId() const + { + return hashId; + } + + void Img::SetId(Str_8 newId) + { + hashId = newId.Hash_64(); + id = (Str_8&&)newId; + } + + Str_8 Img::GetId() const + { + return id; + } + UInt_8 Img::BitDepth() const { return bitDepth; @@ -276,19 +308,19 @@ namespace ehs } case 3: { - Img result(bitDepth, 4, width, height); + Img result(id, bitDepth, 4, width, height); RGB_To_RGBA(result.Size(), result); return result; } case 2: { - Img result(bitDepth, 4, width, height); + Img result(id, bitDepth, 4, width, height); MonoA_To_RGBA(result.Size(), result); return result; } case 1: { - Img result(bitDepth, 4, width, height); + Img result(id, bitDepth, 4, width, height); Mono_To_RGBA(result.Size(), result); return result; } @@ -346,7 +378,7 @@ namespace ehs { case 4: { - Img result(bitDepth, 3, width, height); + Img result(id, bitDepth, 3, width, height); RGBA_To_RGB(result.Size(), result); return result; } @@ -356,13 +388,13 @@ namespace ehs } case 2: { - Img result(bitDepth, 3, width, height); + Img result(id, bitDepth, 3, width, height); MonoA_To_RGB(result.Size(), result); return result; } case 1: { - Img result(bitDepth, 3, width, height); + Img result(id, bitDepth, 3, width, height); Mono_To_RGB(result.Size(), result); return result; } @@ -420,13 +452,13 @@ namespace ehs { case 4: { - Img result(bitDepth, 2, width, height); + Img result(id, bitDepth, 2, width, height); RGBA_To_MonoA(result.Size(), result); return result; } case 3: { - Img result(bitDepth, 2, width, height); + Img result(id, bitDepth, 2, width, height); RGB_To_MonoA(result.Size(), result); return result; } @@ -436,7 +468,7 @@ namespace ehs } case 1: { - Img result(bitDepth, 2, width, height); + Img result(id, bitDepth, 2, width, height); Mono_To_MonoA(result.Size(), result); return result; } @@ -494,19 +526,19 @@ namespace ehs { case 4: { - Img result(bitDepth, 1, width, height); + Img result(id, bitDepth, 1, width, height); RGBA_To_Mono(result.Size(), result); return result; } case 3: { - Img result(bitDepth, 1, width, height); + Img result(id, bitDepth, 1, width, height); RGB_To_Mono(result.Size(), result); return result; } case 2: { - Img result(bitDepth, 1, width, height); + Img result(id, bitDepth, 1, width, height); MonoA_To_Mono(result.Size(), result); return result; } @@ -572,19 +604,19 @@ namespace ehs } case 24: { - Img result(32, channels, width, height); + Img result(id, 32, channels, width, height); BD24_to_BD32(result.Size(), result); return result; } case 16: { - Img result(32, channels, width, height); + Img result(id, 32, channels, width, height); BD16_to_BD32(result.Size(), result); return result; } case 8: { - Img result(32, channels, width, height); + Img result(id, 32, channels, width, height); BD8_to_BD32(result.Size(), result); return result; } @@ -642,7 +674,7 @@ namespace ehs { case 32: { - Img result(24, channels, width, height); + Img result(id, 24, channels, width, height); BD32_to_BD24(result.Size(), result); return result; } @@ -652,13 +684,13 @@ namespace ehs } case 16: { - Img result(24, channels, width, height); + Img result(id, 24, channels, width, height); BD16_to_BD24(result.Size(), result); return result; } case 8: { - Img result(24, channels, width, height); + Img result(id, 24, channels, width, height); BD8_to_BD24(result.Size(), result); return result; } @@ -716,13 +748,13 @@ namespace ehs { case 32: { - Img result(16, channels, width, height); + Img result(id, 16, channels, width, height); BD32_to_BD16(result.Size(), result); return result; } case 24: { - Img result(16, channels, width, height); + Img result(id, 16, channels, width, height); BD24_to_BD16(result.Size(), result); return result; } @@ -732,7 +764,7 @@ namespace ehs } case 8: { - Img result(16, channels, width, height); + Img result(id, 16, channels, width, height); BD8_to_BD16(result.Size(), result); return result; } @@ -790,19 +822,19 @@ namespace ehs { case 32: { - Img result(8, channels, width, height); + Img result(id, 8, channels, width, height); BD32_to_BD8(result.Size(), result); return result; } case 24: { - Img result(8, channels, width, height); + Img result(id, 8, channels, width, height); BD24_to_BD8(result.Size(), result); return result; } case 16: { - Img result(8, channels, width, height); + Img result(id, 8, channels, width, height); BD16_to_BD8(result.Size(), result); return result; } @@ -848,7 +880,7 @@ namespace ehs File file(filePath, Mode::READ, Disposition::OPEN); Str_8 ext = file.GetExtension(); - Img result; + Img result(file.GetName()); const ImgCodec* codec = GetCodec(ext); if (!codec) @@ -881,7 +913,7 @@ namespace ehs return result; } - result = new Img(); + result = new Img(file.GetName()); Serializer data = file.ReadSerializer_64(codec->GetEndianness(), file.Size()); @@ -896,9 +928,9 @@ namespace ehs return result; } - Img Img::FromData(const Str_8& ext, Serializer& data) + Img Img::FromData(Str_8 id, const Str_8& ext, Serializer& data) { - Img result; + Img result((Str_8&&)id); const ImgCodec* codec = GetCodec(ext); if (!codec) @@ -917,7 +949,7 @@ namespace ehs { UInt_8 bytes = bitDepth / 8; - Img result(bitDepth, channels, newWidth, newHeight); + Img result(id, bitDepth, channels, newWidth, newHeight); double xRatio = (double)width / (double)newWidth; double yRatio = (double)height / (double)newWidth; diff --git a/src/io/model/Mesh.cpp b/src/io/model/Mesh.cpp index 15e0d10..bd46dfb 100644 --- a/src/io/model/Mesh.cpp +++ b/src/io/model/Mesh.cpp @@ -3,37 +3,33 @@ namespace ehs { Mesh::Mesh() + : hashId(0) { AddType("Mesh"); } Mesh::Mesh(Str_8 id, Array vertices, Array indices) - : Resource(std::move(id)), vertices(std::move(vertices)), indices(std::move(indices)) + : hashId(id.Hash_64()), id((Str_8&&)id), vertices((Array&&)vertices), + indices((Array&&)indices) { AddType("Mesh"); } Mesh::Mesh(Str_8 id, Array vertices) - : Resource(std::move(id)), vertices(std::move(vertices)) - { - AddType("Mesh"); - } - - Mesh::Mesh(Str_8 id) - : Resource(std::move(id)) + : hashId(id.Hash_64()), id((Str_8&&)id), vertices((Array&&)vertices) { AddType("Mesh"); } Mesh::Mesh(Mesh&& mesh) noexcept - : Resource(std::move(mesh)), vertices(std::move(mesh.vertices)), - indices(std::move(mesh.indices)) + : BaseObj((BaseObj&&)mesh), hashId(mesh.hashId), id((Str_8&&)mesh.id), vertices((Array&&)mesh.vertices), + indices((Array&&)mesh.indices) { + mesh.hashId = 0; } Mesh::Mesh(const Mesh& mesh) - : Resource(mesh), vertices(mesh.vertices), indices(mesh.indices), srcVertBuffer(mesh.srcVertBuffer), - dstVertBuffer(mesh.dstVertBuffer), srcIndBuffer(mesh.srcIndBuffer), dstIndBuffer(mesh.dstIndBuffer) + : BaseObj((BaseObj&&)mesh), hashId(mesh.hashId), id(mesh.id), vertices(mesh.vertices), indices(mesh.indices) { } @@ -42,14 +38,14 @@ namespace ehs if (this == &mesh) return *this; - vertices = std::move(mesh.vertices); - indices = std::move(mesh.indices); - srcVertBuffer = std::move(mesh.srcVertBuffer); - dstVertBuffer = std::move(mesh.dstVertBuffer); - srcIndBuffer = std::move(mesh.srcIndBuffer); - dstIndBuffer = std::move(mesh.dstIndBuffer); + BaseObj::operator=((BaseObj&&)mesh); - Resource::operator=(std::move(mesh)); + hashId = mesh.hashId; + id = (Str_8&&)mesh.id; + vertices = (Array&&)mesh.vertices; + indices = (Array&&)mesh.indices; + + mesh.hashId = 0; return *this; } @@ -59,237 +55,36 @@ namespace ehs if (this == &mesh) return *this; + BaseObj::operator=(mesh); + + hashId = mesh.hashId; + id = mesh.id; vertices = mesh.vertices; indices = mesh.indices; - srcVertBuffer = mesh.srcVertBuffer; - dstVertBuffer = mesh.dstVertBuffer; - srcIndBuffer = mesh.srcIndBuffer; - dstIndBuffer = mesh.dstIndBuffer; - - Resource::operator=(mesh); return *this; } - bool Mesh::UploadToGpu(GpuCmdBuffer* cmdBuffer) + void Mesh::Release() { - GameLoop* gl = (GameLoop*)GetParent("GameLoop"); - if (!gl) - return false; - - RenderWindow* win = gl->GetWindow(); - if (!win) - return false; - - GpuInterface* inf = win->GetInterface(); - - if (readOnly) - { - srcVertBuffer = { - inf, - VK_BUFFER_USAGE_TRANSFER_SRC_BIT, - sizeof(Vertex_f) * vertices.Size() - }; - - Byte* data = (Byte*)srcVertBuffer.MapMemory(); - - for (UInt_64 i = 0; i < vertices.Size(); ++i) - for (UInt_64 v = 0; v < sizeof(Vertex_f); ++v) - data[sizeof(Vertex_f) * i + v] = ((Byte*) &vertices[i])[v]; - - srcVertBuffer.UnMapMemory(); - - dstVertBuffer = { - inf, - VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, - srcVertBuffer.Size(), - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT - }; - - VK_MEMORY_PROPERTY_HOST - - VkBufferMemoryBarrier barrier = {}; - barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - barrier.pNext = nullptr; - barrier.srcAccessMask = 0; - barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.buffer = dstVertBuffer; - barrier.offset = 0; - barrier.size = VK_WHOLE_SIZE; - - cmdBuffer->BufferBarrier( - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, - 1, - &barrier - ); - - GpuBuffer::Copy(cmdBuffer, &srcVertBuffer, &dstVertBuffer); - - barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - barrier.pNext = nullptr; - barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; - barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.buffer = dstVertBuffer; - barrier.offset = 0; - barrier.size = VK_WHOLE_SIZE; - - cmdBuffer->BufferBarrier( - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, - 0, - 1, - &barrier - ); - - if (indices.Size()) - { - srcIndBuffer = { - inf, - VK_BUFFER_USAGE_TRANSFER_SRC_BIT, - sizeof(UInt_32) * indices.Size() - }; - - UInt_32* indMem = (UInt_32*)srcIndBuffer.MapMemory(); - - for (UInt_64 i = 0; i < indices.Size(); ++i) - indMem[i] = indices[i]; - - srcIndBuffer.UnMapMemory(); - - dstIndBuffer = { - inf, - VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, - srcIndBuffer.Size(), - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT - }; - - barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - barrier.pNext = nullptr; - barrier.srcAccessMask = 0; - barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.buffer = dstIndBuffer; - barrier.offset = 0; - barrier.size = VK_WHOLE_SIZE; - - cmdBuffer->BufferBarrier( - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, - 1, - &barrier - ); - - GpuBuffer::Copy(cmdBuffer, &srcIndBuffer, &dstIndBuffer); - - barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - barrier.pNext = nullptr; - barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; - barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.buffer = dstIndBuffer; - barrier.offset = 0; - barrier.size = VK_WHOLE_SIZE; - - cmdBuffer->BufferBarrier( - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, - 0, - 1, - &barrier - ); - } - - cmdBuffer->AddDependency(this); - } - else - { - dstVertBuffer = { - inf, - VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, - sizeof(Vertex_f) * vertices.Size() - }; - - void* data = dstVertBuffer.MapMemory(); - Util::Copy(data, &vertices[0], dstVertBuffer.Size()); - dstVertBuffer.UnMapMemory(); - - if (indices.Size()) - { - dstIndBuffer = { - inf, - VK_BUFFER_USAGE_INDEX_BUFFER_BIT, - sizeof(UInt_32) * indices.Size() - }; - - data = dstIndBuffer.MapMemory(); - Util::Copy(data, &indices[0], dstIndBuffer.Size()); - dstIndBuffer.UnMapMemory(); - } - } - - return true; + vertices.Clear(); + indices.Clear(); } - bool Mesh::PostGpuUpload() + UInt_64 Mesh::GetHashId() const { - srcVertBuffer.Release(); - srcIndBuffer.Release(); - - return true; + return hashId; } - bool Mesh::HasPostGpuUploaded() const + void Mesh::SetId(Str_8 newId) { - return !srcVertBuffer.IsValid() && !srcIndBuffer.IsValid(); + hashId = newId.Hash_64(); + id = (Str_8&&)newId; } - bool Mesh::ReleaseFromGpu() + Str_8 Mesh::GetId() const { - srcVertBuffer.Release(); - srcIndBuffer.Release(); - dstVertBuffer.Release(); - dstIndBuffer.Release(); - - return true; - } - - bool Mesh::IsUploaded() const - { - return dstVertBuffer.IsValid(); - } - - void Mesh::Bind(GpuCmdBuffer* cmdBuffer) - { - cmdBuffer->AddDependency(this); - - if (dstIndBuffer.IsValid()) - { - cmdBuffer->AddDependency(&dstIndBuffer); - vkCmdBindIndexBuffer(*cmdBuffer, dstIndBuffer.GetBuffer(), 0, VK_INDEX_TYPE_UINT32); - } - - cmdBuffer->AddDependency(&dstVertBuffer); - - VkDeviceSize offset = 0; - VkBuffer vertB = dstVertBuffer.GetBuffer(); - vkCmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertB, &offset); - } - - void Mesh::Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances) - { - if (dstIndBuffer.IsValid()) - vkCmdDrawIndexed(*cmdBuffer, indices.Size(), instances, 0, 0, 0); - else - vkCmdDraw(*cmdBuffer, vertices.Size(), instances, 0, 0); + return id; } void Mesh::SetVertices(const Array& newVertices) diff --git a/src/io/model/Model.cpp b/src/io/model/Model.cpp index b5953aa..8ae1f47 100644 --- a/src/io/model/Model.cpp +++ b/src/io/model/Model.cpp @@ -3,6 +3,7 @@ namespace ehs { Model::Model() + : hashId(0) { AddType("Model"); } @@ -23,27 +24,27 @@ namespace ehs } Model::Model(Str_8 id, Array meshes, Bone skeleton, Array animations) - : Resource(std::move(id)), meshes(std::move(meshes)), skeleton(std::move(skeleton)), - animations(std::move(animations)) + : hashId(id.Hash_64()), id((Str_8&&)id), meshes((Array&&)meshes), skeleton((Bone&&)skeleton), + animations((Array&&)animations) { AddType("Model"); } Model::Model(Str_8 id, Array meshes, Bone skeleton) - : Resource(std::move(id)), meshes(std::move(meshes)), skeleton(std::move(skeleton)) + : hashId(id.Hash_64()), id((Str_8&&)id), meshes((Array&&)meshes), skeleton((Bone&&)skeleton) { AddType("Model"); } Model::Model(Str_8 id, Array meshes) - : Resource(std::move(id)), meshes(std::move(meshes)) + : hashId(id.Hash_64()), id((Str_8&&)id), meshes((Array&&)meshes) { AddType("Model"); } Model::Model(Model&& model) noexcept - : Resource(std::move(model)), meshes(std::move(model.meshes)), - skeleton(std::move(model.skeleton)), animations(std::move(model.animations)) + : BaseObj((BaseObj&&)model), hashId(model.hashId), id((Str_8&&)model.id), meshes((Array&&)model.meshes), + skeleton((Bone&&)model.skeleton), animations((Array&&)model.animations) { } @@ -52,60 +53,40 @@ namespace ehs if (this == &model) return *this; + BaseObj::operator=((BaseObj&&)model); + hashId = model.hashId; - id = std::move(model.id); - meshes = std::move(model.meshes); - skeleton = std::move(model.skeleton); - animations = std::move(model.animations); + id = (Str_8&&)model.id; + meshes = (Array&&)model.meshes; + skeleton = (Bone&&)model.skeleton; + animations = (Array&&)model.animations; model.hashId = 0; return *this; } - bool Model::UploadToGpu(GpuCmdBuffer* cmdBuffer) + void Model::Release() { - for (UInt_64 i = 0; i < meshes.Size(); ++i) - if (!meshes[i].UploadToGpu(cmdBuffer)) - return false; - - return true; + meshes.Clear(); + skeleton = {}; + animations.Clear(); } - bool Model::PostGpuUpload() + UInt_64 Model::GetHashId() const { - bool result = true; - - for (UInt_64 i = 0; i < meshes.Size(); ++i) - if (!meshes[i].PostGpuUpload()) - result = false; - - return result; + return hashId; } - bool Model::ReleaseFromGpu() + void Model::SetId(Str_8 newId) { - bool result = true; - - for (UInt_64 i = 0; i < meshes.Size(); ++i) - if (!meshes[i].ReleaseFromGpu()) - result = false; - - return result; + hashId = newId.Hash_64(); + id = (Str_8&&)newId; } - bool Model::IsUploaded() const + Str_8 Model::GetId() const { - return meshes[0].IsUploaded(); - } - - void Model::Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances) - { - for (UInt_64 i = 0; i < meshes.Size(); ++i) - { - meshes[i].Bind(cmdBuffer); - meshes[i].Draw(cmdBuffer, instances); - } + return id; } Array Model::GetMeshes() const @@ -118,18 +99,18 @@ namespace ehs return meshes; } - Mesh* Model::GetMesh(const UInt_64 hashId) + Mesh* Model::GetMesh(const UInt_64 inHashId) { for (UInt_64 i = 0; i < meshes.Size(); ++i) - if (meshes[i].GetHashId() == hashId) + if (meshes[i].GetHashId() == inHashId) return &meshes[i]; return nullptr; } - Mesh* Model::GetMesh(const Str_8& id) + Mesh* Model::GetMesh(const Str_8& inId) { - return GetMesh(id.Hash_64()); + return GetMesh(inId.Hash_64()); } Bone Model::GetSkeleton() const @@ -142,10 +123,10 @@ namespace ehs return skeleton; } - Animation* Model::GetAnimation(const UInt_64 hashId) + Animation* Model::GetAnimation(const UInt_64 inHashId) { for (UInt_64 i = 0; i < animations.Size(); ++i) - if (animations[i].GetHashId() == hashId) + if (animations[i].GetHashId() == inHashId) return &animations[i]; return nullptr; @@ -224,7 +205,6 @@ namespace ehs for (UInt_64 i = 0; i < meshes.Size(); ++i) { meshes[i].SetId(data.ReadStr()); - meshes[i].SetParent(this); Array& vertices = meshes[i].GetVertices(); vertices.Resize(data.Read()); diff --git a/src/io/socket/Comms.cpp b/src/io/socket/Comms.cpp index 98eca75..57594d3 100644 --- a/src/io/socket/Comms.cpp +++ b/src/io/socket/Comms.cpp @@ -226,8 +226,7 @@ namespace ehs payload.WriteVersion(ver); payload.WriteVersion(appVer); - Endpoint* end = new Endpoint(hdl, type, address, port); - end->SetParent(this); + Endpoint* end = new Endpoint(this, type, address, port); end->Send(false, true, false, "Internal", "Connect", payload); endpoints.Push(end); @@ -316,9 +315,8 @@ namespace ehs Architecture rArch = payload.Read(); Str_8 rId = payload.ReadStr(); - Endpoint* end = new Endpoint(hdl, header.disposition, rArch, rId, type, rAddress, rPort); + Endpoint* end = new Endpoint(this, header.disposition, rArch, rId, type, rAddress, rPort); end->SetStatus(Status::PENDING); - end->SetParent(this); Serializer sPayload(Endianness::LE); @@ -415,10 +413,9 @@ namespace ehs Architecture arch = payload.Read(); Str_8 id = payload.ReadStr(); - *end = Endpoint(hdl, header.disposition, arch, id, type, rAddress, rPort); + *end = Endpoint(this, header.disposition, arch, id, type, rAddress, rPort); end->SetStatus(payload.Read()); end->SetQueueSlot(payload.Read()); - end->SetParent(this); if (connectedCb) connectedCb(this, end); diff --git a/src/io/socket/Endpoint.cpp b/src/io/socket/Endpoint.cpp index c3d0135..05f6a33 100644 --- a/src/io/socket/Endpoint.cpp +++ b/src/io/socket/Endpoint.cpp @@ -20,24 +20,24 @@ namespace ehs { Endpoint::Endpoint() - : hdl(EHS_INVALID_SOCKET), disposition(EndDisp::UNKNOWN), status(Status::PENDING), arch(Architecture::UNKNOWN), + : owner(nullptr), disposition(EndDisp::UNKNOWN), status(Status::PENDING), arch(Architecture::UNKNOWN), hashId(0), nextSendId(0), nextRecvId(0), port(0), deltaDuration(0.0f), deltaRate(1.0f / 60.0f), timeout(0.0f), lastPing(0.0f), oldLatency(0.0f), latency(0.0f), queueSlot(0) { AddType("Endpoint"); } - Endpoint::Endpoint(Socket hdl, const EndDisp disposition, const Architecture arch, const Str_8& id, + Endpoint::Endpoint(Comms* owner, const EndDisp disposition, const Architecture arch, const Str_8& id, const AddrType& type, const Str_8& address, const UInt_16 port) - : hdl(hdl), disposition(disposition), status(Status::ACTIVE), arch(arch), id(id), hashId(id.Hash_32()), nextSendId(0), + : owner(owner), disposition(disposition), status(Status::ACTIVE), arch(arch), id(id), hashId(id.Hash_32()), nextSendId(0), nextRecvId(0), address(address), port(port), deltaDuration(0.0f), deltaRate(1.0f / 60.0f), timeout(0.0f), lastPing(0.0f), oldLatency(0.0f), latency(0.0f), queueSlot(0) { AddType("Endpoint"); } - Endpoint::Endpoint(Socket hdl, const AddrType& type, const Str_8& address, const UInt_16 port) - : hdl(hdl), disposition(EndDisp::UNKNOWN), status(Status::PENDING), arch(Architecture::UNKNOWN), hashId(0), + Endpoint::Endpoint(Comms* owner, const AddrType& type, const Str_8& address, const UInt_16 port) + : owner(owner), disposition(EndDisp::UNKNOWN), status(Status::PENDING), arch(Architecture::UNKNOWN), hashId(0), nextSendId(0), nextRecvId(0), address(address), port(port), deltaDuration(0.0f), deltaRate(1.0f / 60.0f), timeout(0.0f), lastPing(0.0f), oldLatency(0.0f), latency(0.0f), queueSlot(0) { @@ -45,7 +45,7 @@ namespace ehs } Endpoint::Endpoint(const Endpoint& end) - : BaseObj(end), hdl(EHS_INVALID_SOCKET), disposition(end.disposition), status(Status::PENDING), arch(end.arch), + : BaseObj(end), owner(nullptr), disposition(end.disposition), status(Status::PENDING), arch(end.arch), id(end.id), hashId(end.hashId), nextSendId(0), nextRecvId(0), address(end.address), port(end.port), deltaDuration(0.0f), deltaRate(1.0f / 60.0f), timeout(0.0f), lastPing(0.0f), oldLatency(0.0f), latency(0.0f), queueSlot(0) @@ -82,7 +82,7 @@ namespace ehs } else { - hdl = EHS_INVALID_SOCKET; + owner = nullptr; disposition = end.disposition; status = Status::PENDING; arch = end.arch; @@ -108,13 +108,6 @@ namespace ehs void Endpoint::Poll(const float delta) { - Comms* comms = (Comms*)GetParent(); - if (!comms) - { - EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object."); - return; - } - SortReceived(); if (deltaDuration >= deltaRate) @@ -129,7 +122,7 @@ namespace ehs for (UInt_64 i = 0; i < sent.Size(); ++i) { sent[i].lastResend += delta; - if (sent[i].lastResend >= comms->GetResendRate()) + if (sent[i].lastResend >= owner->GetResendRate()) { Serializer result(Endianness::LE); result.Write(sent[i].header); @@ -138,17 +131,17 @@ namespace ehs if (sent[i].header.encrypted) Encryption::Encrypt_64(result.Size() - sizeof(bool), &result[sizeof(bool)]); - if (comms->GetAddressType() == AddrType::IPV6) + if (owner->GetAddressType() == AddrType::IPV6) Send_v6(result); - else if (comms->GetAddressType() == AddrType::IPV4) + else if (owner->GetAddressType() == AddrType::IPV4) Send_v4(result); - sent[i].lastResend = Math::Mod(sent[i].lastResend, comms->GetResendRate()); + sent[i].lastResend = Math::Mod(sent[i].lastResend, owner->GetResendRate()); } } } - if (comms->GetDisposition() == EndDisp::SERVICE) + if (owner->GetDisposition() == EndDisp::SERVICE) { lastPing += delta; if (lastPing >= 1.0f) @@ -194,13 +187,6 @@ namespace ehs void Endpoint::Send(const bool deltaLocked, const bool encrypted, const bool ensure, const UInt_64 sys, const UInt_64 op, const Serializer<>& payload) { - Comms* comms = (Comms*)GetParent(); - if (!comms) - { - EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object."); - return; - } - if (deltaLocked && deltaDuration < deltaRate) return; @@ -210,13 +196,13 @@ namespace ehs 1, 0, ensure, - comms->GetDisposition(), - comms->GetHashId(), + owner->GetDisposition(), + owner->GetHashId(), sys, op }; - if ((comms->GetAddressType() == AddrType::IPV6 && payload.Size() > COMMS_IPV6_PAYLOAD) || (comms->GetAddressType() == AddrType::IPV4 && payload.Size() > COMMS_IPV4_PAYLOAD)) + if ((owner->GetAddressType() == AddrType::IPV6 && payload.Size() > COMMS_IPV6_PAYLOAD) || (owner->GetAddressType() == AddrType::IPV4 && payload.Size() > COMMS_IPV4_PAYLOAD)) { Fragments frags = FragmentData(header, payload); for (UInt_64 i = 0; i < frags.Size(); ++i) @@ -380,16 +366,9 @@ namespace ehs Fragments Endpoint::FragmentData(const Header& header, const Serializer<>& data) { - Comms* comms = (Comms*)GetParent(); - if (!comms) - { - EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object."); - return {}; - } - Fragments result; - if (comms->GetAddressType() == AddrType::IPV6) + if (owner->GetAddressType() == AddrType::IPV6) { UInt_64 frags = data.Size() / COMMS_IPV6_PAYLOAD; if (data.Size() % COMMS_IPV6_PAYLOAD) @@ -408,7 +387,7 @@ namespace ehs result[i] = {data.GetEndianness(), &data[i * COMMS_IPV6_PAYLOAD], size}; } } - else if (comms->GetAddressType() == AddrType::IPV4) + else if (owner->GetAddressType() == AddrType::IPV4) { UInt_64 frags = data.Size() / COMMS_IPV4_PAYLOAD; if (data.Size() % COMMS_IPV4_PAYLOAD) @@ -433,13 +412,6 @@ namespace ehs void Endpoint::Send(const Header& header, const Serializer<>& payload) { - Comms* comms = (Comms*)GetParent(); - if (!comms) - { - EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object."); - return; - } - Serializer result(Endianness::LE); result.Write(header); result.WriteSer(payload); @@ -450,9 +422,9 @@ namespace ehs if (header.ensure) sent.Push({header, payload}); - if (comms->GetAddressType() == AddrType::IPV6) + if (owner->GetAddressType() == AddrType::IPV6) Send_v6(result); - else if (comms->GetAddressType() == AddrType::IPV4) + else if (owner->GetAddressType() == AddrType::IPV4) Send_v4(result); } @@ -512,7 +484,7 @@ namespace ehs UInt_16 Endpoint::Send_v6(const Serializer<>& payload) { - if (hdl == EHS_INVALID_SOCKET) + if (!owner) { EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized."); return 0; @@ -549,7 +521,7 @@ namespace ehs return 0; } - Int_32 sent = sendto(hdl, (char*)&payload[0], (int)payload.Size(), 0, (sockaddr*)&result, sizeof(sockaddr_in6)); + Int_32 sent = sendto(owner->hdl, (char*)&payload[0], (int)payload.Size(), 0, (sockaddr*)&result, sizeof(sockaddr_in6)); #if defined(EHS_OS_WINDOWS) if (sent == SOCKET_ERROR) #elif defined(EHS_OS_LINUX) @@ -566,7 +538,7 @@ namespace ehs EHS_LOG_INT("Error", 4, "Failed to send with error #" + Str_8::FromNum(dCode) + "."); - ((Comms*)GetParent())->UnInitialize(); + owner->UnInitialize(); return 0; } @@ -576,7 +548,7 @@ namespace ehs UInt_16 Endpoint::Send_v4(const Serializer<>& payload) { - if (hdl == EHS_INVALID_SOCKET) + if (!owner) { EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized."); return 0; @@ -613,7 +585,7 @@ namespace ehs return 0; } - SInt_64 sent = sendto(hdl, (char*)&payload[0], (int)payload.Size(), 0, (sockaddr*)&result, sizeof(sockaddr_in)); + SInt_64 sent = sendto(owner->hdl, (char*)&payload[0], (int)payload.Size(), 0, (sockaddr*)&result, sizeof(sockaddr_in)); #if defined(EHS_OS_WINDOWS) if (sent == SOCKET_ERROR) #elif defined(EHS_OS_LINUX) @@ -636,7 +608,7 @@ namespace ehs { EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + "."); - ((Comms*)GetParent())->UnInitialize(); + owner->UnInitialize(); } #else Int_32 dCode = 0; diff --git a/src/io/socket/rest/TwitchChat.cpp b/src/io/socket/rest/TwitchChat.cpp index 5099d5e..00f25f6 100644 --- a/src/io/socket/rest/TwitchChat.cpp +++ b/src/io/socket/rest/TwitchChat.cpp @@ -53,7 +53,7 @@ namespace ehs if (initialized) return; - client = TCP(lwe::AddrType::IPV4); + client = TCP(ehs::AddrType::IPV4); client.Connect(DNS::Resolve(AddrType::IPV4, "irc.chat.twitch.tv"), 6667); client.SetBlocking(false); diff --git a/src/system/CPU_GCC_AMD64.asm b/src/system/CPU_GCC_AMD64.asm index 98a5cc0..8b2592a 100644 --- a/src/system/CPU_GCC_AMD64.asm +++ b/src/system/CPU_GCC_AMD64.asm @@ -1,22 +1,22 @@ -global _ZN3lwe3CPU6RDTSCPEPNS_3TSCE -global _ZN3lwe3CPU15GetManufacturerEPc -global _ZN3lwe3CPU11GetInfoBitsEv -global _ZN3lwe3CPU16GetFeatureBits_1Ev -global _ZN3lwe3CPU16GetFeatureBits_2Ev -global _ZN3lwe3CPU19GetExtFeatureBits_1Ev -global _ZN3lwe3CPU19GetExtFeatureBits_2Ev -global _ZN3lwe3CPU19GetExtFeatureBits_3Ev -global _ZN3lwe3CPU8GetBrandEPc +global _ZN3ehs3CPU6RDTSCPEPNS_3TSCE +global _ZN3ehs3CPU15GetManufacturerEPc +global _ZN3ehs3CPU11GetInfoBitsEv +global _ZN3ehs3CPU16GetFeatureBits_1Ev +global _ZN3ehs3CPU16GetFeatureBits_2Ev +global _ZN3ehs3CPU19GetExtFeatureBits_1Ev +global _ZN3ehs3CPU19GetExtFeatureBits_2Ev +global _ZN3ehs3CPU19GetExtFeatureBits_3Ev +global _ZN3ehs3CPU8GetBrandEPc section .text - _ZN3lwe3CPU6RDTSCPEPNS_3TSCE: + _ZN3ehs3CPU6RDTSCPEPNS_3TSCE: RDTSCP MOV DWORD [RDI], ECX MOV DWORD [RDI + 4], EDX MOV DWORD [RDI + 8], EAX RET - _ZN3lwe3CPU15GetManufacturerEPc: + _ZN3ehs3CPU15GetManufacturerEPc: PUSH RBX XOR EAX, EAX @@ -30,7 +30,7 @@ section .text RET - _ZN3lwe3CPU11GetInfoBitsEv: + _ZN3ehs3CPU11GetInfoBitsEv: PUSH RBX MOV EAX, 1 @@ -40,7 +40,7 @@ section .text RET - _ZN3lwe3CPU16GetFeatureBits_1Ev: + _ZN3ehs3CPU16GetFeatureBits_1Ev: PUSH RBX MOV EAX, 1 @@ -52,7 +52,7 @@ section .text RET - _ZN3lwe3CPU16GetFeatureBits_2Ev: + _ZN3ehs3CPU16GetFeatureBits_2Ev: PUSH RBX MOV EAX, 1 @@ -64,7 +64,7 @@ section .text RET - _ZN3lwe3CPU19GetExtFeatureBits_1Ev: + _ZN3ehs3CPU19GetExtFeatureBits_1Ev: PUSH RBX MOV EAX, 7 @@ -77,7 +77,7 @@ section .text RET - _ZN3lwe3CPU19GetExtFeatureBits_2Ev: + _ZN3ehs3CPU19GetExtFeatureBits_2Ev: PUSH RBX MOV EAX, 7 @@ -90,7 +90,7 @@ section .text RET - _ZN3lwe3CPU19GetExtFeatureBits_3Ev: + _ZN3ehs3CPU19GetExtFeatureBits_3Ev: PUSH RBX MOV EAX, 7 @@ -103,7 +103,7 @@ section .text RET - _ZN3lwe3CPU8GetBrandEPc: + _ZN3ehs3CPU8GetBrandEPc: PUSH RBX MOV EAX, 80000002h diff --git a/src/system/CPU_MSVC_AMD64.asm b/src/system/CPU_MSVC_AMD64.asm index a43c345..67faf9c 100644 --- a/src/system/CPU_MSVC_AMD64.asm +++ b/src/system/CPU_MSVC_AMD64.asm @@ -1,14 +1,14 @@ -global ?GetManufacturer@CPU@lwe@@SAXPEAD@Z -global ?GetInfoBits@CPU@lwe@@SAIXZ -global ?GetFeatureBits_1@CPU@lwe@@SAIXZ -global ?GetFeatureBits_2@CPU@lwe@@SAIXZ -global ?GetExtFeatureBits_1@CPU@lwe@@SAIXZ -global ?GetExtFeatureBits_2@CPU@lwe@@SAKXZ -global ?GetExtFeatureBits_3@CPU@lwe@@SAKXZ -global ?GetBrand@CPU@lwe@@SAXPEAD@Z +global ?GetManufacturer@CPU@ehs@@SAXPEAD@Z +global ?GetInfoBits@CPU@ehs@@SAIXZ +global ?GetFeatureBits_1@CPU@ehs@@SAIXZ +global ?GetFeatureBits_2@CPU@ehs@@SAIXZ +global ?GetExtFeatureBits_1@CPU@ehs@@SAIXZ +global ?GetExtFeatureBits_2@CPU@ehs@@SAKXZ +global ?GetExtFeatureBits_3@CPU@ehs@@SAKXZ +global ?GetBrand@CPU@ehs@@SAXPEAD@Z section .text - ?GetManufacturer@CPU@lwe@@SAXPEAD@Z: + ?GetManufacturer@CPU@ehs@@SAXPEAD@Z: PUSH RBX XOR EAX, EAX @@ -23,7 +23,7 @@ section .text RET - ?GetInfoBits@CPU@lwe@@SAIXZ: + ?GetInfoBits@CPU@ehs@@SAIXZ: PUSH RBX MOV EAX, 1 @@ -33,7 +33,7 @@ section .text RET - ?GetFeatureBits_1@CPU@lwe@@SAIXZ: + ?GetFeatureBits_1@CPU@ehs@@SAIXZ: PUSH RBX MOV EAX, 1 @@ -45,7 +45,7 @@ section .text RET - ?GetFeatureBits_2@CPU@lwe@@SAIXZ: + ?GetFeatureBits_2@CPU@ehs@@SAIXZ: PUSH RBX MOV EAX, 1 @@ -57,7 +57,7 @@ section .text RET - ?GetExtFeatureBits_1@CPU@lwe@@SAIXZ: + ?GetExtFeatureBits_1@CPU@ehs@@SAIXZ: PUSH RBX MOV EAX, 7 @@ -70,7 +70,7 @@ section .text RET - ?GetExtFeatureBits_2@CPU@lwe@@SAKXZ: + ?GetExtFeatureBits_2@CPU@ehs@@SAKXZ: PUSH RBX MOV EAX, 7 @@ -83,7 +83,7 @@ section .text RET - ?GetExtFeatureBits_3@CPU@lwe@@SAKXZ: + ?GetExtFeatureBits_3@CPU@ehs@@SAKXZ: PUSH RBX MOV EAX, 7 @@ -96,7 +96,7 @@ section .text RET - ?GetBrand@CPU@lwe@@SAXPEAD@Z: + ?GetBrand@CPU@ehs@@SAXPEAD@Z: PUSH RBX MOV R8, RCX