diff --git a/BigBaseV2/src/script_local.cpp b/BigBaseV2/src/script_local.cpp new file mode 100644 index 00000000..f6bffa3a --- /dev/null +++ b/BigBaseV2/src/script_local.cpp @@ -0,0 +1,31 @@ +#include "common.hpp" +#include "pointers.hpp" +#include "script_local.hpp" +#include "gta\script_thread.hpp" + +namespace big +{ + script_local::script_local(rage::scrThread* thread, std::size_t index) : + m_index(index), m_stack(thread->m_stack) + { + } + script_local::script_local(PVOID stack, std::size_t index) : + m_index(index), m_stack(stack) + { + } + + script_local script_local::at(std::ptrdiff_t index) + { + return script_local(m_stack, m_index + index); + } + + script_local script_local::at(std::ptrdiff_t index, std::size_t size) + { + return script_local(m_stack, m_index + 1 + (index * size)); + } + + void *script_local::get() + { + return reinterpret_cast((uintptr_t)m_stack + (m_index * sizeof(uintptr_t))); + } +} diff --git a/BigBaseV2/src/script_local.hpp b/BigBaseV2/src/script_local.hpp new file mode 100644 index 00000000..e7d08573 --- /dev/null +++ b/BigBaseV2/src/script_local.hpp @@ -0,0 +1,31 @@ +#pragma once +#include "common.hpp" + +namespace big +{ + class script_local + { + public: + explicit script_local(rage::scrThread* thread, std::size_t index); + explicit script_local(PVOID stack, std::size_t index); + + script_local at(std::ptrdiff_t index); + script_local at(std::ptrdiff_t index, std::size_t size); + + template + std::enable_if_t, T> as() + { + return static_cast(get()); + } + + template + std::enable_if_t, T> as() + { + return *static_cast>>(get()); + } + private: + void *get(); + std::size_t m_index; + PVOID m_stack; + }; +} diff --git a/README.md b/README.md index 70e2e6b5..ebd27de7 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,8 @@ To build BigBaseV2 you need: To set up the build environment, run the following commands in a terminal: ```dos -git clone https://github.com/Pocakking/BigBaseV2.git --recurse-submodules -cd BigBaseV2 +git clone https://gir489@bitbucket.org/gir489/bigbasev2-fix.git --recurse-submodules +cd BigBaseV2-fix GenerateProjects.bat ``` Now, you will be able to open the solution, and simply build it in Visual Studio. - -It is reccomended you generate the project each time you add a file instead of adding it directly to Visual Studio. - -## Credits -Pocakking - Original creator. - -gir489 - Implementer and wrote the g3log crash handler and added test cases. - -datlimabean04 - Wrote the g3log and settings implementation. \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index db9a089c..9681119c 100644 --- a/premake5.lua +++ b/premake5.lua @@ -142,6 +142,9 @@ workspace "BigBaseV2" if(file_exists("vendor\\g3log\\src\\g3log\\generated_definitions.hpp") == false) then file = io.open("vendor\\g3log\\src\\g3log\\generated_definitions.hpp", "w") + if(file == nil) then + premake.error("Failed to locate vendor directories. Try doing git pull --recurse-submodules.") + end file:write("// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG\n\n\n/* ==========================================================================\n*2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes\n* with no warranties. This code is yours to share, use and modify with no\n\n*strings attached and no restrictions or obligations.\n* \n* For more information see g3log/LICENSE or refer refer to http://unlicense.org\n\n*============================================================================*/\n#pragma once\n\n\n// CMake induced definitions below. See g3log/Options.cmake for details."); end