From 33582ace4738ea7fe89c647b3f97c91bdcac5265 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Tue, 19 Mar 2024 16:07:37 +0300 Subject: [PATCH] Forgot to upload this essential file --- src/DivaGL/types.hpp | 250 +++++++++++++++++++++++-------------------- 1 file changed, 132 insertions(+), 118 deletions(-) diff --git a/src/DivaGL/types.hpp b/src/DivaGL/types.hpp index 54f9e3c..f263cfe 100644 --- a/src/DivaGL/types.hpp +++ b/src/DivaGL/types.hpp @@ -1,118 +1,132 @@ -/* - by korenkonder - GitHub/GitLab: korenkonder - - Original: Allocator.h, Types.h by blueskythlikesclouds from DivaModLoader -*/ - -#include "../KKdLib/default.hpp" -#include -#include -#include - -#pragma once - -namespace prj { - typedef enum HeapCMallocType { - HeapCMallocSystem = 0x00, - HeapCMallocTemp = 0x01, - HeapCMallocMode = 0x02, - HeapCMallocEvent = 0x03, - HeapCMallocDebug = 0x04, - HeapCMallocMax = 0x05, - } HeapCMallocType; - - static void* (*HeapCMallocAllocate)(HeapCMallocType type, size_t size, const char* name) - = (void* (*)(HeapCMallocType, size_t, const char*))0x00000001403F2A00; - static void* (*HeapCMallocAllocateByType)(HeapCMallocType type, size_t size, const char* name) - = (void* (*)(HeapCMallocType, size_t, const char*))0x0000000140181C30; - static void(*HeapCMallocFree)(HeapCMallocType type, void* data) - = (void(*)(HeapCMallocType, void*))0x00000001403F2960; - static void(*HeapCMallocFreeByType)(HeapCMallocType type, void* data) - = (void(*)(HeapCMallocType, void*))0x0000000140182DB0; -}; - -static void* (*_operator_new)(size_t) = (void* (*)(size_t))0x000000014084530C; -static void(*_operator_delete)(void*) = (void(*)(void*))0x0000000140845378; - -static float_t(*get_anim_frame_speed)() = (float_t(*)())0x0000000140192CC0; -static float_t(*get_delta_frame)() = (float_t(*)())0x0000000140192D50; - -template -class Allocator { -public: - using value_type = T; - - Allocator() noexcept {} - template Allocator(Allocator const&) noexcept {} - - value_type* allocate(std::size_t n) { - return reinterpret_cast(_operator_new(n * sizeof(value_type))); - } - - void deallocate(value_type* p, std::size_t) noexcept { - _operator_delete(reinterpret_cast(p)); - } -}; - -template -bool operator==(Allocator const&, Allocator const&) noexcept { - return true; -} - -template -bool operator!=(Allocator const& x, Allocator const& y) noexcept { - return !(x == y); -} - -namespace prj { - template - using pair = std::pair; - - using string = std::basic_string, Allocator>; - - template - using vector = std::vector>; - - template - using list = std::list>; - - template - using map = std::map, Allocator>>; - - template - class ref_count { - private: - int32_t uses; - int32_t weaks; - T* ptr; - void(*delete_this_func)(ref_count* ref); - void(*destroy_func)(ref_count* ref, T* ptr); - }; - - template - class shared_ptr; - - template - class ptr_base { - private: - T* ptr; - ref_count* ref; - - template - friend class ptr_base; - }; - - template - class shared_ptr : public ptr_base { - public: - }; - - template - struct sorted_vector { - vector> field_0; - size_t field_18; - vector> field_20; - bool field_38; - }; -} +/* + by korenkonder + GitHub/GitLab: korenkonder + + Original: Allocator.h, Types.h by blueskythlikesclouds from DivaModLoader +*/ + +#include "../KKdLib/default.hpp" +#include +#include +#include +#include +#include +#include + +#pragma once + +namespace prj { + typedef enum HeapCMallocType { + HeapCMallocSystem = 0x00, + HeapCMallocTemp = 0x01, + HeapCMallocMode = 0x02, + HeapCMallocEvent = 0x03, + HeapCMallocDebug = 0x04, + HeapCMallocMax = 0x05, + } HeapCMallocType; + + static void* (*HeapCMallocAllocate)(HeapCMallocType type, size_t size, const char* name) + = (void* (*)(HeapCMallocType, size_t, const char*))0x00000001403F2A00; + static void* (*HeapCMallocAllocateByType)(HeapCMallocType type, size_t size, const char* name) + = (void* (*)(HeapCMallocType, size_t, const char*))0x0000000140181C30; + static void(*HeapCMallocFree)(HeapCMallocType type, void* data) + = (void(*)(HeapCMallocType, void*))0x00000001403F2960; + static void(*HeapCMallocFreeByType)(HeapCMallocType type, void* data) + = (void(*)(HeapCMallocType, void*))0x0000000140182DB0; +}; + +static void* (*_operator_new)(size_t) = (void* (*)(size_t))0x000000014084530C; +static void(*_operator_delete)(void*) = (void(*)(void*))0x0000000140845378; + +static float_t(*get_anim_frame_speed)() = (float_t(*)())0x0000000140192CC0; +static float_t(*get_delta_frame)() = (float_t(*)())0x0000000140192D50; + +template +class Allocator { +public: + using value_type = T; + + Allocator() noexcept {} + template Allocator(Allocator const&) noexcept {} + + value_type* allocate(std::size_t n) { + return reinterpret_cast(_operator_new(n * sizeof(value_type))); + } + + void deallocate(value_type* p, std::size_t) noexcept { + _operator_delete(reinterpret_cast(p)); + } +}; + +template +bool operator==(Allocator const&, Allocator const&) noexcept { + return true; +} + +template +bool operator!=(Allocator const& x, Allocator const& y) noexcept { + return !(x == y); +} + +namespace prj { + template + using pair = std::pair; + + using string = std::basic_string, Allocator>; + + using wstring = std::basic_string, Allocator>; + + template + using vector = std::vector>; + + template + using list = std::list>; + + template + using map = std::map, Allocator>>; + + template + using set = std::set, Allocator>; + + template + using unordered_map = std::unordered_map, std::equal_to, Allocator>>; + + template + using unordered_set = std::unordered_set, std::equal_to, Allocator>; + + template + class ref_count { + private: + int32_t uses; + int32_t weaks; + T* ptr; + void(*delete_this_func)(ref_count* ref); + void(*destroy_func)(ref_count* ref, T* ptr); + }; + + template + class shared_ptr; + + template + class ptr_base { + private: + T* ptr; + ref_count* ref; + + template + friend class ptr_base; + }; + + template + class shared_ptr : public ptr_base { + public: + }; + + template + struct sorted_vector { + vector> field_0; + size_t field_18; + vector> field_20; + bool field_38; + }; +}